home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE4 / POWERBASE / PB384 / !Powerbase / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  2002-11-09  |  481KB  |  22,092 lines

  1.  ><PBase$Dir>.!RunImage
  2.  !RunImage for !Powerbase database
  3.  D.L. Haslam & S.R. Haslam
  4.  Heap Manager (module + BASIC)
  5.  S.R. Haslam
  6.  Rendered 32-bit compatible by Christopher Bazley (03-11-2002)
  7.  Documentation and source code by Harriet Bazley available on website
  8.  Dial utility
  9.  Justin Fletcher
  10.  Helpreader (system for on-line help text)
  11.  Ben Summers
  12.  New high-res icons for files
  13.  Lenny <lenny@argonet.co.uk>
  14.  http://www.argonet.co.uk/users/lenny/index.html
  15. ,:                                       
  16.  version$="8.34 (06-10-2002)"
  17.  Adapted to comply with anti-aliased desktop font in RISC OS 3.5 & later
  18.  Can use scrollable lists.
  19.  Printing uses RISC OS drivers.
  20.  Direct mail-merging with OvationPro requires v.1.3 of !Impulse applet
  21. ,"Error: "+
  22. $+" during initialisation at line "+
  23.  "Hourglass_On"
  24.  "OS_Byte",228,1
  25.  "OS_Byte",202,0,255 
  26.  ,kbdstatus%
  27.  block% &1C00,msgnum% 4
  28.  "OS_ReadVarVal","Pbase$Dir",block%,255 
  29. #?block%?L%=13:program$=
  30. leaf($block%):progname$=
  31. program$,2)
  32. PbaseDir$=leafnamepath$
  33.  program$ automatically reflects whatever name application is called
  34.  It is used in Wimp_Initialise so this name appears on task list
  35.  Also inserted into Info box.
  36. check_resources:
  37.  ### Check for missing files ###
  38.  ### All present & correct. Initialise Wimp & Impulse module ###
  39. $block%="TASK":!msgnum%=0
  40. mask%=(1<<4)+(1<<5)
  41.  "Wimp_Initialise",300,!block%,progname$,msgnum% 
  42.  version%,mytask%
  43.  version%<310 
  44.  0,"This version of Powerbase is only suitable for RISC OS 3.10 or greater. Contact Powerbase Support for a suitable version."
  45.  "Impulse_Initialise",003,mytask%,"Powerbase",-1
  46.  Do NOT use progname$ here or client tasks trying to interrogate
  47.  "Powerbase" will not have their Impulse commands recognized!
  48. initheaps(128,128)
  49.  ### Load message file so that 'proper' error-handler can be used ###
  50.  msgbuff% &100,param$(3),att$(3)
  51. 4'f$="<PBase$Dir>.Resources.Messages"
  52.  "MessageTrans_FileInfo",,f$ 
  53.  flags%,,len%
  54.  errormsg% len%
  55.  "OS_Module",6,,,17+
  56. (f$) 
  57.  ,,filedesc%
  58. $(filedesc%+16)=f$
  59.  "MessageTrans_OpenFile",filedesc%,filedesc%+16,errormsg%
  60. : fatal_err%=255:moan_err%=254
  61. wimp_error(
  62.  Mi% 20,Mo% 20
  63. getscreensize(ScreenWidth%,ScreenHeight%,Vpix%)
  64.  "XWimp_ReadSysInfo",8 
  65.  Desktopfont%;flags%
  66.  (flags% 
  67.  Desktopfont%=0
  68.  ### Load private sprites ###
  69.  "OS_File",5,"<PBase$Dir>.Resources.Sprites22" 
  70.  d%,,,,len%
  71.  sprites% len%+4
  72. !sprites%=len%+4
  73. load_sprites
  74.  ### Get Internet addresses ###
  75. ("<Pbase$Dir>.Resources.Internet")
  76. Web$=
  77. #F:Email$=
  78. close_file(F)
  79. get_configuration("<Pbase$Dir>.Resources.Config","main")
  80. dim_arrays(MaxFields%+12,MaxKeys%,MaxTabs%,MaxCols%,MaxLists%,MaxLibs%)
  81. printer_palette
  82. allocate_buffers
  83. load_functionkeys
  84. init_vars
  85. create_anchors
  86. impulse_methods
  87. create_windows
  88. make_menus
  89. get_defaults
  90. select(prefsW%,36):
  91. deselect(prefsW%,35):
  92. shade(prefsW%,35,
  93. select(csvW%,19):
  94. deselect(csvW%,18)
  95. scroll_icons(MaxCols%)
  96.  "OS_ReadMonotonicTime" 
  97.  ReturnAfter%
  98. ReturnEvery%=100
  99. ReturnAfter%+=ReturnEvery%
  100. banner
  101. iconbar_icon("")
  102. `9present%=
  103. :library$="":toolheight%=770:padheight%=316
  104. find_libraries(CustDir$,MaxSize%,NextLib%,MaxLibs%)
  105.  ### Respond to double-click on database when Powerbase not yet running ###
  106.  "OS_GetEnv" 
  107.  ComString$
  108. ComString$,"-database") 
  109. f4  File$=
  110. ComString$,
  111. ComString$,"-database")+10)
  112.  "OS_GSTrans",File$,
  113. 13),255 
  114.  ,File$,L%
  115.   File$=
  116. File$,L%)
  117. get_it_in(File$)
  118. shade(passW%,17,
  119.  Allows use of Access Control List. Change to FALSE if not wanted
  120. set_return
  121. wimp_error(
  122.  ### Establish place to jump back to once we start polling ###
  123.  ### Now ready to roll! ###
  124.  "Hourglass_Off"
  125. poll(
  126.  quit%
  127. close_down
  128. poll(idle%)
  129.  "OS_Byte",229,1:
  130.  "OS_Byte",124
  131.  idle% 
  132.  "Wimp_PollIdle",mask%,block%,ReturnAfter% 
  133.  reason%
  134.  "Wimp_Poll",mask%,block% 
  135.  reason%
  136.  reason% 
  137.  autosave%>0 
  138.  Access%=
  139. check_save(
  140. ($Interval%))
  141.  Impulse_wait% 
  142.  merging% 
  143. start_merge(mergeW%)
  144.  flash%>0 
  145. &    
  146. invert(mainW%,field%(flash%))
  147.  OLE%>0 
  148. check_date_stamp
  149. set_return
  150. redraw(!block%)
  151. open_it(!block%)
  152. close_it(!block%)
  153. mouse(block%!0,block%!4,block%!8,block%!12,block%!16)
  154. end_drag
  155. process_key
  156. menu_select
  157.  !block%=mainW% 
  158.  returnto%=block%!4:
  159.  "OS_Byte",202,caps%,111
  160. set_keyboard(!block%,block%!4)
  161.  17,18:
  162.  "Impulse_Decode",reason%,block%,,,,methodtable%,mytask% 
  163.  reason%,,,,,token%,params%,object%
  164.  reason%>=&200 
  165.  reason% 
  166. V      
  167.  &200,&201:
  168.  token%<>-1 
  169. Impulse_command_received(token%,params%,object%)
  170. /      
  171.  &202:
  172. Impulse_reply(token%,params%)
  173. .      
  174.  &203:
  175. Impulse_send(token%,object%)
  176. 9      
  177.  &204:
  178. Impulse_receive(token%,params%,object%)
  179.         
  180. message
  181. not_acknowledged
  182. complete(N%)
  183.  Allows windows to redraw inside long procedures
  184.  I%=1 
  185. poll(
  186. check_date_stamp
  187.  "OS_File",5,OLE$ 
  188.  ,,,r3%
  189.  r3%<>OLEDS% 
  190. update_external(REC%):OLEDS%=r3%
  191. set_return
  192.  time%
  193.  "OS_ReadMonotonicTime" 
  194.  time%
  195.  time%-ReturnAfter%>0
  196.    ReturnAfter%+=ReturnEvery%
  197.  Shutdown routines ---------------------------------------------------
  198. close_down
  199. #0:$block%="TASK":
  200.  "Wimp_CloseDown",mytask%,!block%:
  201. ,"Error: "+
  202. $+" during closedown at line "+
  203.  "Hourglass_Smash"
  204.  "Impulse_CloseDown",mytask%
  205. $block%="TASK"
  206.  "Wimp_CloseDown",mytask%,!block%
  207.  flags%,F,Postpone%
  208.  special%(10) 
  209. (libfunc$+"_function(10)")
  210.  Postpone% 
  211.  "Hourglass_Smash"
  212.  "OS_File",5,$database% 
  213.  d%=2 
  214.  "XOS_Find",128,$database%+".Junk" 
  215.  F;flags%
  216.  (flags% 
  217.  1)=0 
  218. @    
  219. close_file(F):
  220.  "OS_CLI","Remove "+$database%+".Junk" 
  221.  present%=7 
  222. 6      
  223. save_marks:
  224. clear_marks(RA%):
  225. warn_of_marks
  226.       
  227. save_winpos
  228. /      
  229.  ramwarn% 
  230.  ram% 
  231. softerror("",63)
  232.         
  233. F    
  234.  design% 
  235.  protect% 
  236.  force% 
  237. save_form($database%+".Form")
  238. %    
  239.  altered% 
  240. save_everything
  241. memory_usage
  242. auto_csv(
  243.      
  244. blob_deleterestore("D")
  245. close_files
  246.     link$()="":calc$()=""
  247. #    
  248. close_log("<Log$Dir>.Log")
  249. softerror("",218)
  250.  $database%<>"No data" 
  251. softerror("",145)
  252. kill_scrollers(
  253. hide_windows
  254. delete_icons(mainW%,0)
  255. delete_icons(numscrollW%,0)
  256.  ic%=24 
  257. text(keypadW%,ic%)=""
  258. deselect(matchW%,4):
  259. deselect(matchW%,6):
  260. deselect(matchW%,12)
  261. recover_memory
  262. init_vars
  263. get_defaults
  264. read_colours("<Pbase$Dir>.Resources.FieldCols")
  265. CSHkeyptr%()=-1:SHtabptr%()=-1:SHundoptr%()=-1:SHscrollptr%()=-1
  266. $Subfilename%="Subfile 0"
  267. $NewName%="!NewName"
  268. select(prefsW%,36):
  269. deselect(prefsW%,35):
  270. shade(prefsW%,35,
  271.  I%=0 
  272.  LastTable%
  273.   printrel$(I%)=""
  274.  tableW%(I%)>0 
  275.  !block%=tableW%(I%):
  276.  "Wimp_DeleteWindow",,block%
  277.   tableW%()=0:TabTitle%()=0
  278. tableW%()=0:TabTitle%()=0
  279. field$()="":ephemera$()=""
  280. $Password%=""
  281. $$Records%="100":$Increment%="25"
  282. present%=
  283. exit%=
  284.  I%=0 
  285. lit(utilityM%,I%,
  286. lit(iconbarM%,1,
  287. lit(iconbarM%,2,
  288. lit(iconbarM%,3,
  289. lit(iconbarM%,4,
  290. lit(validateM%,1,
  291. ):ptr%=validateM%+52:ptr%!4=-1
  292. lit(indexM%,1,
  293. ):ptr%=indexM%+52:ptr%!4=-1
  294. lit(printM%,5,
  295. lit(printM%,7,
  296. lit(printM%,8,
  297. lit(printM%,9,
  298. lit(mainM%,7,
  299. text(prefsW%,45)="":
  300. shade(prefsW%,45,
  301.  "OS_CLI","Unset Acl$Dir"
  302.  "OS_CLI","Unset Log$Dir"
  303.  "OS_CLI","Unset Dbase$Dir"
  304. $database%="No data"
  305. iconbar_icon("No data")
  306. special%()=
  307.  "OS_Byte",202,kbdstatus%
  308. save_everything
  309.  Access% 
  310. save_links
  311. save_calcs
  312. save_subfilenames
  313. save_keys
  314. save_all_tables
  315.   changed%=
  316. update_calcs(0)
  317. asterisk(
  318. delete_icons(wi%,ic%)
  319. !block%=wi%:block%!4=ic%
  320.  "Wimp_DeleteIcon",,block%
  321.   ic%+=1:block%!4=ic%
  322.  "Wimp_GetIconState",,block%
  323.  ((block%!24) 
  324.  (1<<23))>0
  325. close_files
  326.  Check all file-handles from 1-255 for open files
  327.  Check if open files belong to Powerbase or the database
  328.  If so, close them and report
  329.  F%,V%,P%,F$
  330.  F%=1 
  331.  "XOS_Args",7,F%,block%,,,256 
  332.  (V% 
  333.  1)=0 
  334.     P%=0
  335.  P%+=1
  336.  block%?P%=0
  337.     block%?P%=13
  338. 59    
  339. $block%,program$)>0 
  340. $block%,$database%)>0 
  341. 6(      F$=
  342. "   "+
  343. (F%),3)+" "+$block%
  344.       
  345. 8S      
  346. wimp_error(
  347. ,254,0,"File "+F$+" was left open. It has now been closed.")
  348. 9        
  349. close_file(printhandle%)
  350. close_file(csvhandle%)
  351.  Need to close printer file explicitly since pathname doesn't show
  352.  any connection with Powerbase or database
  353. close_file(
  354.  filehandle%)
  355.  filehandle%>0 
  356. #filehandle%
  357.   filehandle%=0
  358. recover_memory
  359. scrap_block(headanchor%)
  360. scrap_block(lineanchor%)
  361. scrap_block(textanchor%)
  362. scrap_block(formanchor%)
  363. scrap_block(selanchor%)
  364. scrap_block(tempanchor%)
  365. scrap_block(balanchor%)
  366. scrap_block(flaganchor%)
  367. scrap_block(transanchor%)
  368. scrap_block(sprsanchor%)
  369. scrap_block(titleanchor%)
  370. scrap_block(recanchor%)
  371. scrap_block(saveanchor%)
  372. scrap_block(logoanchor%)
  373. scrap_block(fieldmenuanchor%)
  374. scrap_block(usermenuanchor%)
  375. scrap_block(tablemenuanchor%)
  376. scrap_block(indexmenuanchor%)
  377. scrap_block(markanchor%)
  378. scrap_block(blankanchor%)
  379. scrap_block(fontanchor%)
  380. scrap_block(urlanchor%)
  381. scrap_block(sortanchor%)
  382.  I%=0 
  383.  MaxTabs%
  384. scrap_block(tabanchor%(I%))
  385. scrap_block(undoanchor%(I%))
  386.  I%=0 
  387.  MaxKeys%+1
  388. scrap_block(keyanchor%(I%))
  389.  I%=0 
  390.  MaxLists%-1
  391. scrap_block(scrollanchor%(I%))
  392.  I%=1 
  393.  fields%
  394.  present%=7 
  395.  chartype%(I%)=40 
  396. scrap_block(Rf%(I%))
  397.  Error handling ------------------------------------------------------
  398. wimp_error(return%,err%,erl%,err$)
  399.  type%,result%
  400. close_down:
  401. ,"Error: "+
  402. $+" during error handler at line "+
  403.  "Wimp_CommandWindow",-1
  404. block%!0=err%
  405.  return% 
  406.  err%<>fatal_err% 
  407.  err%=moan_err% 
  408. {9    type%=17:
  409.  OK button and no "Error from" in title
  410. |        
  411. }'    type%=3:
  412.  OK and Cancel buttons
  413. ~@    err$+=" at "+
  414. (erl%)+" (OK to continue, Cancel to quit)"
  415.   type%=2:
  416.  Cancel buttom
  417. ,  err$+=" (Powerbase must quit at once)"
  418. close_files
  419. recover_memory
  420. $(block%+4)=err$+
  421.  "Wimp_ReportError",block%,type%,"Powerbase"+
  422.  ,result%
  423.  result=1 means OK selected, 2 means Cancel selected
  424.  result%=2 
  425. close_down
  426. softerror(E$,E%)
  427.  E%>0 
  428.   M$="Err"+
  429.  E$<>"" 
  430.  M$+=","+E$
  431.   $(block%+4)=
  432. msg(M$)
  433.  $(block%+4)=E$
  434. !block%=255
  435.  "Wimp_ReportError",block%,1+(1<<8)+(1<<9),"Powerbase","!powerbase"
  436. confirm(string$)
  437. !block%=255
  438. $(block%+4)=string$+
  439.  "Wimp_ReportError",block%,19,"Powerbase: please confirm"+
  440.  ,result%
  441. =result%=1
  442. inform(M$,M%,T%)
  443.  M$="" 
  444. text(informW%,0)=
  445. msg("Err"+
  446. (M%))
  447. text(informW%,0)=M$
  448. position_window(informW%,0,0,0,0,0,0)
  449. complete(4)
  450.  T%>0 
  451. (T%*100):
  452. close_window(informW%)
  453.  ### Use MessageTrans to display a message from the Messages file ###
  454. msg(token$)
  455.  result$,msgparams$,S$,P%,Q%,p%
  456. param$()=""
  457. token$,",")
  458.  P%>0 
  459. "  msgparams$=
  460. token$,P%+1)+","
  461.   token$=
  462. token$,P%-1)
  463.   P%=0
  464.     Q%=P%+1
  465.     P%=
  466. msgparams$,",",Q%)
  467.  P%>0 
  468. "      S$=
  469. msgparams$,Q%,P%-Q%)
  470. !      S$=
  471. replace(S$,"\",",")
  472.       param$(p%)=S$
  473.       p%+=1
  474.         
  475.  P%=0
  476.  "MessageTrans_Lookup",filedesc%,token$,msgbuff%,&100,param$(0),param$(1),param$(2),param$(3) 
  477.  ,,result$
  478. =result$
  479. replace(S$,found$,with$)
  480.   P%=
  481. S$,found$)
  482.  P%>0 
  483. S$,P%,1)=with$
  484.  P%=0
  485. asterisk(on%)
  486.  on% 
  487. $RecInfo%)<>"*" 
  488.  $RecInfo%+=" *":ramwarn%=
  489. $RecInfo%)="*" 
  490.  $RecInfo%=
  491. $RecInfo%))
  492. altered%=on%
  493. E!block%=mainW%:
  494.  "Wimp_GetWindowOutline",,block%:ymax%=block%!16
  495.  "Wimp_GetWindowState",,block%
  496.  "Wimp_ForceRedraw",-1,block%!4,block%!16,block%!12,ymax%
  497. create_anchors
  498. )headanchor%=
  499. create_anchor("Heading")
  500. *lineanchor%=
  501. create_anchor("TextLine")
  502. &textanchor%=
  503. create_anchor("Text")
  504. &formanchor%=
  505. create_anchor("Form")
  506. .sprsanchor%=
  507. create_anchor("DbaseSprites")
  508. -titleanchor%=
  509. create_anchor("DbaseTitle")
  510. &tempanchor%=
  511. create_anchor("Temp")
  512. (balanchor%=
  513. create_anchor("Balance")
  514. 'flaganchor%=
  515. create_anchor("Flags")
  516. /transanchor%=
  517. create_anchor("DataTransfer")
  518. )selanchor%=
  519. create_anchor("PrintSel")
  520. *recanchor%=
  521. create_anchor("RecordNum")
  522. ,saveanchor%=
  523. create_anchor("SaveBuffer")
  524. &logoanchor%=
  525. create_anchor("Logo")
  526. 0fieldmenuanchor%=
  527. create_anchor("FieldMenu")
  528. .usermenuanchor%=
  529. create_anchor("UserMenu")
  530. 0tablemenuanchor%=
  531. create_anchor("TableMenu")
  532. 0indexmenuanchor%=
  533. create_anchor("IndexMenu")
  534. &markanchor%=
  535. create_anchor("Mark")
  536. (blankanchor%=
  537. create_anchor("Blank")
  538. 'fontanchor%=
  539. create_anchor("Fonts")
  540. $urlanchor%=
  541. create_anchor("URL")
  542. &sortanchor%=
  543. create_anchor("Sort")
  544.  I%=0 
  545.  MaxKeys%+1
  546. 2  keyanchor%(I%)=
  547. create_anchor("Key #"+
  548. (I%))
  549.  I%=0 
  550.  MaxTabs%
  551. 5  tabanchor%(I%)=
  552. create_anchor("VTable #"+
  553. (I%))
  554. :  undoanchor%(I%)=
  555. create_anchor("UndoVTable #"+
  556. (I%))
  557.  I%=0 
  558.  MaxLists%-1
  559. :  scrollanchor%(I%)=
  560. create_anchor("Scroller #"+
  561. (I%))
  562. impulse_methods
  563.  PASS=0 
  564. P%=methodtable%
  565.   [OPT PASS
  566.         equd    0
  567. )        
  568. method(0,1,"GetPathname","")
  569. '        
  570. method(0,2,"Selection","")
  571. (        
  572. method(0,3,"ParseQuery","")
  573. '        
  574. method(0,4,"GetRecord","")
  575. '        
  576. method(0,5,"PutRecord","")
  577. (        
  578. method(0,6,"ExpandCode","")
  579. &        
  580. method(0,7,"GetField","")
  581. )        
  582. method(0,8,"GetExpanded","")
  583. '        
  584. method(0,9,"NextMatch","")
  585.          
  586. method(-1,-1,"","")
  587.  PASS
  588. method(Flags,Token,Method$,Syntax$)
  589. [OPT PASS
  590.         equd    Flags
  591.         equd    Token
  592.          equs    Method$+
  593.          equs    Syntax$+
  594.         align
  595.     =PASS
  596. iconbar_icon(name$)
  597.  len%,old%
  598.  name$ 
  599. 3  $dbase%="No data":len%=
  600. string_width($dbase%)
  601. \  pbaseicon%=
  602. create_icon(0,-1,0,-16,len%,110,&1700312B,"",dbase%,psprite%,
  603. ($dbase%)+1)
  604. /  $dbase%=name$:len%=
  605. string_width($dbase%)
  606.   old%=pbaseicon%
  607. _  pbaseicon%=
  608. create_icon(old%,-3,0,-16,len%,110,&1700312B,"",dbase%,psprite%,
  609. ($dbase%)+1)
  610.   !block%=-1:block%!4=old%
  611.  "Wimp_DeleteIcon",,block%
  612. load_sprites
  613.  Loads private sprites during program initialisation
  614.  Also called if screen resolution changes
  615.  x%,y%,f$,f1$
  616.  "OS_ReadModeVariable",-1,4 
  617.  ,,x%
  618.  "OS_ReadModeVariable",-1,5 
  619.  ,,y%
  620.  x%=1 
  621.  y%=1 
  622.  f$="!Sprites22":f1$="Sprites22"
  623.  (x%=2 
  624.  y%=2) 
  625.  (y%<>x%) 
  626.  f$="!Sprites":f1$="Sprites"
  627.  "OS_CLI","IconSprites <Pbase$Dir>."+f$
  628.  "OS_File",255,"<PBase$Dir>.Resources."+f1$,sprites%+4
  629. banner
  630.  d%,F,S$,f$
  631. text(bannerW%,6)="v. "+version$
  632. 4'f$="<Pbase$Dir>.Resources.Temp.pbr"
  633.  "OS_File",5,f$ 
  634.  d%=1 
  635. register
  636.  "OS_File",5,"<Pbase$Dir>.reg" 
  637.  d%=1 
  638. ("<Pbase$Dir>.reg")
  639. #F,S$:S$=
  640. encrypt(S$,
  641. close_file(F)
  642. </  $
  643. text(infoW%,9)=S$:$
  644. text(bannerW%,5)=S$
  645. =1  $
  646. text(bannerW%,2)="":$
  647. text(bannerW%,3)=""
  648. >+  $
  649. text(bannerW%,4)="Registered user:"
  650. set_icon_cols(infoW%,9,23)
  651.  d%=0 
  652.  Bannertime%>0 
  653. position_window(bannerW%,0,0,0,0,0,0)
  654. complete(10)
  655. >500 
  656.  (d%=1 
  657. >Bannertime%)
  658.  Display 5 sec for unregistered copy, otherwise for configured time
  659.  Skip banner altogether if registered & configured time=0
  660. close_window(bannerW%)
  661. title(area%,x%,y%,ww%,wh%)
  662.  sw%,sh%,mult%,div%,factor,ex%,ey%
  663. "OS_SpriteOp",512+40,area%,area%+area%!8 
  664.  ,,,sw%,sh%
  665. sw%=sw%*2:sh%=sh%*2
  666. r1%=ww%/sw%:r2%=wh%/sh%
  667.  r1%<=r2% 
  668.   mult%=ww%:div%=sw%
  669.  mult%=wh%:div%=sh%
  670.  mult%=mult%*0.9
  671. W x%+=(ww%-sw%*mult%/div%) 
  672. X y%+=(wh%-sh%*mult%/div%) 
  673. Y=!scale%=mult%:scale%!4=mult%:scale%!8=div%:scale%!12=div%
  674.  "ColourTrans_SelectTable",area%,area%+area%!8,-1,-1,wdtrans%,3
  675.  "OS_SpriteOp",512+52,area%,area%+area%!8,x%,y%,0,scale%,wdtrans%
  676. get_defaults
  677.  path$
  678. `"path$="<Pbase$Dir>.Resources."
  679. get_configuration(path$+"Config","main")
  680. get_preferences(prefsW%,path$+"Preference")
  681. get_csv_options(path$+"CSVoptions")
  682. get_options(printW%,printerW%,path$+"!PrintOpts")
  683. allocate_buffers
  684. h(indirectionmem%=&6000:menumem%=&3000
  685.  buffbase% indirectionmem%:endbuff%=buffbase%+indirectionmem%:buff%=buffbase%
  686.  menuindir% &100:menubuff%=menuindir%
  687.  iconblock% &100,paneblock% &600,savebuff% &400,choices% &100,remember% &1000
  688.  menblk% menumem%:men_end%=menblk%+menumem%:menu_ptr%=menblk%
  689.  methodtable% 256:
  690.  For Impulse module
  691.  utctime% 5,datebuffer% 16,dateformat% 16,ordinals% 36:
  692.  For date & time
  693.  date% 6:$date%=
  694. (0)):
  695.  For subfile updates
  696.  key 256,calcrow% 128,hide% 128,mandatory% 128,zerolen% 128,displayit% 128
  697.  fontbuff% &100
  698.  menhelpblock% &100
  699.  paint% 8:$paint%="file_ff9"
  700.  winsp% 20:$winsp%="R5;Swindow,pwindow"
  701.  hand% 16:$hand%="Pptr_hand,4,0"
  702.  writep% 16:$writep%="Pptr_write,4,4"
  703.  writenum% 20:$writenum%="Pptr_write,4,4;A0-9"
  704.  tick% 12:$tick%="Snull,yes"
  705.  dbase% 20:$dbase%="No data"
  706.  psprite% 15:$psprite%="S!"+progname$
  707.  menspr% 30,mentxt% 1:$menspr%="Sgright,pgright;Pptr_menu;R5":$mentxt%=""
  708.  winspr% 20,wintxt% 1:$winspr%="R5;Swindow":$wintxt%=""
  709.  transform% 16,rectangle% 16,rectangle2% 16:
  710.  For printer
  711.  origin%(4):
  712.  For printer
  713.  I%=1 
  714.  P% 8:origin%(I%)=P%
  715.  scale% 16,wdtrans% 256
  716.  Pcol% 4
  717. dim_arrays(F%,K%,T%,C%,L%,LB%)
  718.  desc%(F%),Tag$(F%),field%(F%+1),F$(F%),Rf%(F%)
  719.  len%(F%),maxlen%(F%),truelen%(F%),diff%(F%),maxlenP%(F%),Tab%(F%),Tab2%(F%)
  720.  numeric%(F%),chartype%(F%),fix%(F%)
  721.  link$(F%),calc$(F%),field$(F%),cfield$(F%),update$(F%)
  722.  ephemera$(9,4)
  723.  Date%(5)
  724.  Index$(K%+1),KL%(K%+1),KW%(K%+1,3),KF%(K%+1,3)
  725. 3Index$(0)="PrimaryKey":Index$(K%+1)="Temporary"
  726.  key$(K%+1),case%(K%+1),incspace%(K%+1),null%(K%+1)
  727.  keyfield%(3),WD%(3),Ext%(10)
  728.  Label$(48,20)
  729.  ftypeM%(7),fmenu$(7),flist%(7),choice$(4)
  730.  table$(T%+1),tableW%(T%),TabTitle%(T%),printrel$(T%)
  731.  tabfieldlen%(C%),rel%(C%),tabhead$(C%,1)
  732.  fcol%(10),wimpcol%(15)
  733.  Subfile%(5),filemem%(5,K%)
  734.  buttonfield%(1,28),winbuff%(4,1)
  735.  live%(20)
  736. MC%=30:
  737.  L%(MC%)
  738.  menfield%(30,1)
  739.  SHkeyptr%(K%+1),keyanchor%(K%+1)
  740.  SHtabptr%(T%),SHundoptr%(T%),tabanchor%(T%),undoanchor%(T%)
  741.  scrollerW%(L%-1),scrolldata%(L%-1,9),sclen%(L%-1,3)
  742.  SHscrollptr%(L%-1),scrollanchor%(L%-1)
  743.  lib$(LB%),lib%(LB%),special%(10):special%()=
  744.  scroller_ptr%(L%-1),pending%(L%-1),scrcol%(L%-1)
  745. init_vars
  746. SHclaim%=4096
  747. 5SHtextptr%=0:SHrecptr%=0:SHheadptr%=0:SHurlptr%=0
  748. 4SHformptr%=0:SHsaveptr%=0:SHfontmenu%=0:fontM%=0
  749. 8caps%=16:filemem%()=-1:dragbutt%=0:direc%=1:userM%=0
  750. vfirstsearch%=
  751. :firstfilter%=
  752. :protect%=
  753. :force%=
  754. :qbe%=
  755. :valstatus%=
  756. :clip%=
  757. :pasting%=
  758. :returnto%=-1:ShowTools%=
  759. 1getrec%=213:ClientSearch$="TRUE":ClientPtr%=0
  760. RImpulse_wait%=
  761. :merging%=
  762. :mergenum%=0:document$="":importingcsv%=
  763. :Run_It$=""
  764. -mergetag%=214:transtag%=215:printtag%=216
  765. 8flash%=
  766. :logosloaded%=
  767. :logging%=
  768. :acl%=
  769. :up_pend%=
  770. `accessbutton%=0:stop%=
  771. :customise%=
  772. :valtablesM%=0:indexesM%=0:undo%=
  773. :filter%=
  774. :reformat%=
  775. &displayed%=-1:scratchpad$="":k$=""
  776. oSearch$="TRUE":Filter$="TRUE":query$="ALL":SearchKey$="":REC%=-1:usekey%=-1:useval$="":ResKEY$="":ResREC%=0
  777. greal$="":visible$="":val$="":calcfield%=0:savefunc$="":savetofile%=
  778. :writetable%=
  779. :writescroller%=
  780. @password$="":pw%=0:my_ref%=-1:Type%=0:fieldtype%=1:Length%=0
  781. Bprinting%=
  782. :indexing%=
  783. :not%=
  784. :dontincrement%=
  785. :updatethese%=
  786. -export%=
  787. :csvconv%=
  788. :mergefiles%=
  789. :OLE%=0
  790. 7autosave%=0:autobalance%=
  791. :dupwarn%=
  792. :duplicates%=0
  793. $sorton%=0:sortfield%=0:nosort%=
  794. .present%=0:fields%=0:template%=0:adjust%=
  795. 7Listed%=
  796. :writingcsv%=
  797. :writingtext%=
  798. :calcerror%=
  799. #autocsvhandle%=0:printhandle%=0
  800. "movetype%=8:movetype$="Move 
  801. vquit%=
  802. :exit%=
  803. :matching%=
  804. :newrec%=
  805. :val%=
  806. :ram%=
  807. :Access%=
  808. :Modify%=
  809. :ramwarn%=
  810. :altered%=
  811. :design%=
  812. :newtree%=
  813. HLenLine%=0:Count%=0:labcount%=0:Printable%=0:Start%=0:End%=0:Fptr%=0
  814. 0Fieldnumber%=0:Lastwritable%=0:starthere%=-1
  815. ALastTable%=-1:Tablenumber%=0:TabsLoaded$="Tables":table$()=""
  816. 5Rows%=0:TabFields%=0:Rec%=0:Match_tag%=1:fast%=10
  817. WKeys%=0:keylimit%=1:keylen%=1:LH%=90:addr=-1:file%=0:key%=0:top=8*file%+LH%:RA%=100
  818. +keyfunc$="":fieldfunc$="":Keys%=0:RU%=0
  819. Rprintorder$="":Form$="":ImpCom$="":format$="horiz":shrink%=
  820. :shrinkscroller%=
  821. EFilename$="":TextName$="":extrakeys$="":extratabs$="":indexes$=""
  822. !Days$="SunMonTueWedThuFriSat"
  823. 2Months$="JanFebMarAprMayJunJulAugSepOctNovDec"
  824. 'nonleap$="312831303130313130313031"
  825. $leap$="312931303130313130313031"
  826. SaveCount%=0
  827. BScrollnum%=0:Scroller%=0:ScrollChanged%=
  828. :Scrcol%=0:Scrcol$=""
  829.  I%=0 
  830.  125 
  831. >  hide%!I%=0:mandatory%!I%=0:zerolen%!I%=0:displayit%!I%=0
  832. nosave%=
  833. :dragfield%=0
  834. Ecalc%=0
  835. oldwindow%=0:oldicon%=0
  836. dbtype$="new"
  837. menunumber%=0:lasttype%=0
  838. printer_palette
  839.  I%=0 
  840.  wimpcol%(I%)
  841.  &ffffff00,&dedede00,&bababa00,&99999900
  842.  &78787800,&54545400,&33333333,&00000000
  843.  &ff000000,&00ffff00,&00ff0000,&0000ff00
  844.  &80eded00,&00875400,&00baff00,&ffba0000
  845.  Window handling -----------------------------------------------------
  846. create_windows
  847.  "Wimp_OpenTemplate",,"<Pbase$Dir>.Resources.Templates"
  848. +bannerW%=
  849. new_window("banner",sprites%)
  850.  infoW%=
  851. new_window("info",1)
  852. text(infoW%,4)=progname$:$
  853. text(infoW%,7)=version$
  854.  Tools%=1 
  855.  name$="keypad" 
  856.  name$="toolpane"
  857. 9keypadW%=
  858. new_window(name$,sprites%):Title%=block%!72
  859. zsavesubW%=
  860. new_window("savesub",sprites%):SubName%=
  861. text(savesubW%,2):SubSprite%=
  862. val(savesubW%,0):SubTitle%=block%!72
  863. UsaveW%=
  864. new_window("save",1):SaveName%=
  865. text(saveW%,2):SaveSprite%=
  866. val(saveW%,0)
  867. xaccessW%=
  868. new_window("access",sprites%):UserID%=
  869. text(accessW%,0):Password%=
  870. text(accessW%,1):AccessTitle%=block%!72
  871. passW%=
  872. new_window("password",sprites%):Read%=
  873. text(passW%,2):Write%=
  874. text(passW%,3):Manager%=
  875. text(passW%,5):LogSprite%=
  876. val(passW%,19)
  877. BaclW%=
  878. new_window("aclist",sprites%):AclSprite%=
  879. val(aclW%,15)
  880. :mainW%=
  881. new_window("main",sprites%):RecInfo%=block%!72
  882. >keyW%=
  883. new_window("keystruc",sprites%):KeyTitle%=block%!72
  884. BchangeW%=
  885. new_window("change",sprites%):ChangeTitle%=block%!72
  886. 'moveW%=
  887. new_window("move",sprites%)
  888. NtabcreateW%=
  889. new_window("tabcreate",sprites%):tabcol%=
  890. text(tabcreateW%,8)
  891. $scrollW%=
  892. new_window("scroll",0)
  893. .numscrollW%=
  894. new_window("scroll",sprites%)
  895. linkW%=
  896. new_window("link",sprites%):LinkTitle%=block%!72:Tablename%=
  897. text(linkW%,0):fieldnum%=
  898. text(linkW%,2):substitute%=
  899. text(linkW%,10)
  900. OmiscW%=
  901. new_window("misc",1):database%=
  902. text(miscW%,1):$database%="No data"
  903.  ic%=2 
  904. $  Date%(ic%-2)=
  905. text(miscW%,ic%)
  906.  ic%=28 
  907. (  Subfile%(ic%-28)=
  908. text(miscW%,ic%)
  909. Oused%=
  910. text(miscW%,17):filesize%=
  911. text(miscW%,18):percent%=
  912. text(miscW%,14)
  913. )printW%=
  914. new_window("print",sprites%)
  915. ;matchW%=
  916. new_window("match",sprites%):oldquery%=matchW%
  917. 'listW%=
  918. new_window("list",sprites%)
  919. XcreateW%=
  920. new_window("create",sprites%):FtitleText%=block%!72:$FtitleText%="Field 0"
  921. DescText%=
  922. text(createW%,4):TagText%=
  923. text(createW%,5):LenText%=
  924. text(createW%,6):ValText%=
  925. text(createW%,28):InsText%=
  926. text(createW%,26)
  927. )Fixpt%=
  928. text(createW%,13):$Fixpt%="2"
  929. ;mintext%=
  930. text(createW%,15):maxtext%=
  931. text(createW%,25)
  932. dboxX%=
  933. text(createW%,7):boxY%=
  934. text(createW%,8):boxW%=
  935. text(createW%,9):boxH%=
  936. text(createW%,10)
  937. ArelateW%=
  938. new_window("relation",sprites%):RelTitle%=block%!72
  939. +reformW%=
  940. new_window("reform",sprites%)
  941.  ReformSprite%=FNval(reformW%,0):$ReformSprite%="snew_appl;Pptr_hand,4,0;R2"
  942.     ZOriginal%=
  943. text(reformW%,3):Reformatted%=
  944. text(reformW%,6):Newform%=
  945. text(reformW%,12)
  946. RmergebaseW%=
  947. new_window("mergebase",sprites%):MergeSprite%=
  948. val(mergebaseW%,7)
  949. &colW%=
  950. new_window("cols",sprites%)
  951. read_colours("<Pbase$Dir>.Resources.FieldCols")
  952. VcalcW%=
  953. new_window("calc",sprites%):CalcForm%=
  954. text(calcW%,0):CalcTitle%=block%!72
  955. -printerW%=
  956. new_window("printer",sprites%)
  957. -pselectW%=
  958. new_window("pselect",sprites%)
  959. 2extracalcW%=
  960. new_window("extracalcs",sprites%)
  961. FmergeW%=
  962. new_window("merge",sprites%):ImpulseApp%=
  963. text(mergeW%,9)
  964. PsizeW%=
  965. new_window("size",sprites%):Records%=
  966. text(sizeW%,1):$Records%="100"
  967. /Increment%=
  968. text(sizeW%,3):$Increment%="25"
  969. =csvW%=
  970. new_window("csvfile",sprites%):CSVTitle%=block%!72
  971. <fkeyW%=
  972. new_window("fkey",sprites%):FkeyTitle%=block%!72
  973. 7Kpadicon%=
  974. val(fkeyW%,0):Fkeyequiv%=
  975. text(fkeyW%,3)
  976. )prefsW%=
  977. new_window("prefs",sprites%)
  978. 7datesep%=
  979. text(prefsW%,1):timesep%=
  980. text(prefsW%,4)
  981. .wc%=
  982. text(prefsW%,7):ws%=
  983. text(prefsW%,10)
  984.  mergewith%=
  985. text(prefsW%,17)
  986. 8Interval%=
  987. text(prefsW%,25):Every%=
  988. text(prefsW%,32)
  989. 5StartHere%=
  990. text(prefsW%,45):
  991. shade(prefsW%,45,
  992. )queryW%=
  993. new_window("query",sprites%)
  994. &Query%=
  995. text(queryW%,0):$Query%=""
  996. 'helpW%=
  997. new_window("help",sprites%)
  998.  +filterW%=
  999. new_window("filter",sprites%)
  1000. !+searchW%=
  1001. new_window("search",sprites%)
  1002. "'gridW%=
  1003. new_window("grid",sprites%)
  1004. #CGridspace%=
  1005. text(gridW%,8):Gridsnap%=
  1006. text(gridW%,9):
  1007. grid_opts
  1008. $$informW%=
  1009. new_window("inform",0)
  1010. %'markW%=
  1011. new_window("mark",sprites%)
  1012. &TinputW%=
  1013. new_window("input",0):Prompt%=
  1014. text(inputW%,0):Params%=
  1015. text(inputW%,1)
  1016. '"titleW%=
  1017. new_window("title",0)
  1018. ((mergecomW%=
  1019. new_window("mergecom",1)
  1020.  "Wimp_CloseTemplate"
  1021. *Jwinbuff%()=csvW%,0,passW%,700,printerW%,1000,printW%,2300,prefsW%,3000
  1022. scroll_icons(rows%)
  1023.  I%=0 
  1024.  rows%
  1025.   iflags%=&0700F735
  1026. 0Y  R%=
  1027. create_icon(0,scrollW%,4,-I%*44-52,64,48,iflags%,"",buff%,writenum%,4):buff%+=4
  1028.   iflags%=&0700F535
  1029. 2[  R%=
  1030. create_icon(0,scrollW%,66,-I%*44-52,212,48,iflags%,"",buff%,writep%,13):buff%+=13
  1031. 4#!block%=0:block%!4=-rows%*44-56
  1032. block%!8=284:block%!12=0
  1033.  "Wimp_SetExtent",scrollW%,block%
  1034. new_window(name$,sp%)
  1035.  handle%
  1036.  "Wimp_LoadTemplate",,block%,buff%,endbuff%,fontbuff%,name$,0 
  1037.  ,,buff%
  1038.  name$="main" 
  1039.  block%?35=winback%
  1040. block%!64=sp%
  1041.  "Wimp_CreateWindow",,block% 
  1042.  handle%
  1043. =handle%
  1044. show_windows
  1045. check_record
  1046. open_window(mainW%)
  1047.  present%=7 
  1048.  Tools%=1 
  1049.  ShowTools%=
  1050. open_window(keypadW%)
  1051.  Listed% 
  1052. open_window(listW%)
  1053. store_window(wi%,buff%)
  1054.  ic%,ptr%
  1055. K'!block%=wi%:block%!4=ic%:ptr%=buff%
  1056.  "Wimp_GetIconState",,block%
  1057.  ((block%!24) 
  1058.  (1<<23))=0
  1059.   !ptr%=block%!24:ptr%+=4
  1060.  ((block%?25) 
  1061.  1)>0 
  1062.  $ptr%=$
  1063. text(wi%,ic%):ptr%+=block%!36
  1064. P%  !block%=wi%:ic%+=1:block%!4=ic%
  1065.  "Wimp_GetIconState",,block%
  1066. restore_window(wi%,buff%)
  1067.  ic%,ptr%
  1068. W'!block%=wi%:block%!4=ic%:ptr%=buff%
  1069.  "Wimp_GetIconState",,block%
  1070.  ((block%!24) 
  1071.  (1<<23))=0
  1072. ZI  !block%=wi%:block%!4=ic%:block%!8=!ptr%:block%!12=&ffffffff:ptr%+=4
  1073.  "Wimp_SetIconState",,block%
  1074.  ((block%?25) 
  1075.  1)>0 
  1076. text(wi%,ic%)=$ptr%:ptr%+=block%!36
  1077. ]%  !block%=wi%:ic%+=1:block%!4=ic%
  1078.  "Wimp_GetIconState",,block%
  1079. open_window(wi%)
  1080. block%!0=wi%
  1081.  "Wimp_GetWindowState",,block%
  1082. block%!28=-1
  1083. open_it(wi%)
  1084. open_it(wi%)
  1085.  win%
  1086.  wi% 
  1087.  mainW%:
  1088.  ShowTools% 
  1089.  Tools%=2 
  1090. update_pane(keypadW%,-154,0,152,toolheight%,0,0)
  1091.  markpane% 
  1092. update_pane(markW%,0,block%!16-block%!8+2,696,62,0,0)
  1093.  Scrollnum%>0 
  1094.  design%=
  1095.  I%=0 
  1096.  Scrollnum%-1
  1097.       
  1098. update_pane(scrollerW%(I%),scrolldata%(I%,1)-block%!20+2,block%!24-scrolldata%(I%,2)-scrolldata%(I%,4)+2,scrolldata%(I%,3),scrolldata%(I%,4)-4,0,0)
  1099.  HasTitle%=1 
  1100. uK    
  1101. update_pane(titleW%,0,0,block%!12-block%!4,block%!16-block%!8,0,0)
  1102.  "Wimp_OpenWindow",,block%
  1103.  tabcreateW%:
  1104. update_pane(scrollW%,16,160,284,232,0,0)
  1105.  pselectW%:
  1106. update_pane(numscrollW%,8,50,740,196,0,0)
  1107.  matchW%:
  1108. update_pane(queryW%,340,8,466,174,0,0)
  1109.  changeW%:
  1110. update_pane(queryW%,18,202,466,174,0,0)
  1111.  moveW%:
  1112. update_pane(queryW%,18,312,466,138,0,0)
  1113.  savesubW%:
  1114. update_pane(queryW%,10,40,466,174,0,0):
  1115. redraw_icon(wi%,0):
  1116.  filterW%:
  1117. update_pane(queryW%,8,52,466,138,0,0)
  1118.  keypadW%:
  1119.  Tools%=1 
  1120. Q    !paneblock%=wi%:
  1121.  "Wimp_GetWindowState",,paneblock%:flags%=paneblock%!32
  1122.  flags% 
  1123.  (1<<19) 
  1124. ,      
  1125.  paneblock%!16-paneblock%!8>100 
  1126. 9        block%!4=paneblock%!4:block%!12=paneblock%!12
  1127. :        block%!16=paneblock%!16:block%!8=block%!16-100
  1128.         
  1129. 9        block%!4=paneblock%!4:block%!12=paneblock%!12
  1130. J        block%!16=paneblock%!16:block%!8=block%!16-padheight%         
  1131.       
  1132.         
  1133. $    
  1134.  "Wimp_OpenWindow",,block%
  1135.  "Wimp_OpenWindow",,block%
  1136.  win%=0 
  1137.  winbuff%(win%,0)=wi% 
  1138. store_window(wi%,remember%+winbuff%(win%,1))
  1139.  win%
  1140. close_it(wi%)
  1141.  wi% 
  1142.  mainW%:
  1143.  altered% 
  1144. save_everything
  1145. kill_scrollers(
  1146. hide_windows:stop%=
  1147.  HasTitle%>0 
  1148. close_window(titleW%)
  1149.  matchW%:matching%=
  1150. close_window(queryW%)
  1151.  keyW%:design%=
  1152. :newtree%=
  1153.  tabcreateW%:
  1154. close_window(scrollW%)
  1155.  pselectW%:
  1156. close_window(numscrollW%)
  1157.  changeW%,moveW%,savesubW%,filterW%:
  1158. close_window(queryW%)
  1159. close_window(wi%)
  1160.  T%=0 
  1161.  LastTable%
  1162.  wi%=tableW%(T%) 
  1163. restore_caret(returnto%)
  1164. hide_windows
  1165. close_window(queryW%)
  1166. close_window(keypadW%)
  1167.  I%=0 
  1168.  LastTable%
  1169.  tableW%(I%)>0 
  1170. close_window(tableW%(I%))
  1171. close_window(miscW%)
  1172. close_window(listW%)
  1173. close_window(matchW%)
  1174. close_window(relateW%)
  1175. close_window(keyW%)
  1176. close_window(reformW%)
  1177. close_window(calcW%)
  1178. close_window(mergeW%)
  1179. close_window(csvW%)
  1180. close_window(passW%)
  1181. close_window(aclW%)
  1182. close_window(tabcreateW%)
  1183. close_window(prefsW%)
  1184. close_window(printW%)
  1185. close_window(printerW%)
  1186. close_window(linkW%)
  1187. close_window(changeW%)
  1188. close_window(savesubW%)
  1189. close_window(moveW%)
  1190. close_window(searchW%)
  1191. close_window(filterW%)
  1192. close_window(helpW%)
  1193. close_window(createW%)
  1194. close_window(mainW%)
  1195. close_window(informW%)
  1196. close_window(markW%)
  1197. close_window(colW%)
  1198. close_window(inputW%)
  1199. close_window(titleW%)
  1200. close_window(extracalcW%)
  1201. close_window(wi%)
  1202. !block%=wi%
  1203.  "Wimp_CloseWindow",,block%
  1204. shut_window(wi%)
  1205.  "Wimp_TransferBlock",mytask%,block%,mytask%,paneblock%,88
  1206.  wi%=filterW% 
  1207. filter_click(filterW%,1,4) 
  1208. close_it(wi%)
  1209.  "Wimp_TransferBlock",mytask%,paneblock%,mytask%,block%,88
  1210. redraw(handle%)
  1211.  x0%,y0%,more%
  1212. !block%=handle%
  1213.  "Wimp_RedrawWindow",,block% 
  1214.  more%
  1215. 2x0%=block%!4-block%!20:y0%=block%!16-block%!24
  1216.  more%
  1217. draw(x0%,y0%)
  1218.  "Wimp_GetRectangle",,block% 
  1219.  more%
  1220. draw(x0%,y0%)
  1221.  TextPtr%,x1%,x2%,y1%,y2%,X%,Y%,line%,chars%,colour%,YS%,YL%,L%,b%,t%
  1222.  handle% 
  1223.  titleW%:
  1224. title(SHtitleptr%,block%!4,block%!8,block%!12-block%!4,block%!16-block%!8)
  1225.  mainW%:
  1226.  design% 
  1227.  showgrid% 
  1228.     int%=
  1229. ($Gridspace%)
  1230. $    
  1231.  "Wimp_SetColour",gridcol%
  1232. #    
  1233.  X%=x0% 
  1234.  block%!12 
  1235.  int%
  1236.       
  1237.  X%,block%!8
  1238.       
  1239.  plot%,X%,block%!16
  1240. #    
  1241.  Y%=y0% 
  1242.  block%!8 
  1243.  -int%
  1244.       
  1245.  block%!4,Y%
  1246.       
  1247.  plot%,block%!12,Y%
  1248.  listW%:
  1249.  "Wimp_SetColour",7
  1250.   x1%=block%!28-x0%
  1251.   x2%=block%!36-x0%
  1252.   chars%=(x2%-x1%) 
  1253.  16+2
  1254.   y1%=-(block%!40-y0%)
  1255.   y2%=-(block%!32-y0%)
  1256.   x1%=x1% 
  1257.   y1%=y1% 
  1258.  36+1
  1259.   y2%=y2% 
  1260.  36+2
  1261.   SHtextptr%=!textanchor%
  1262. 0  TextPtr%=(SHtextptr%)+(y1%-1)*LenLine%+x1%
  1263. #  RecPtr%=(SHrecptr%)+(y1%-1)*4
  1264.  y2%>Count% 
  1265.  y2%=Count%
  1266.  line%=y1% 
  1267.  !RecPtr% 
  1268. (      
  1269.  -1,-2:colour%=headerwimpcol%
  1270. #      
  1271.  -3:colour%=rulewimpcol%
  1272.        
  1273. :colour%=bodywimpcol%
  1274.         
  1275. #    
  1276.  "Wimp_SetColour",colour%
  1277.  !RecPtr%=-3 
  1278. Q      
  1279.  x0%+Lmargin%*16,y0%-(line%-1)*36-18:
  1280.  BY (LenLine%-Lmargin%-2)*16+8,0
  1281.       
  1282. draw_line
  1283.         
  1284. %    TextPtr%+=LenLine%:RecPtr%+=4
  1285.  line%
  1286.  vrules% 
  1287. (    
  1288.  "Wimp_SetColour",rulewimpcol%
  1289. G    YS%=block%!8:b%=Count%*36-y0%+block%!8-fspace%:
  1290.  b%<0 
  1291.  YS%-=b%
  1292. ;    YF%=block%!16:t%=hspace%+block%!24:
  1293.  t%>0 
  1294.  YF%-=t%
  1295.     L%=
  1296. (spacer$)*8
  1297.     column%=2
  1298.      
  1299.  column%<=PrintFields%
  1300. $      X%=x0%+Tab%(column%)*16-L%
  1301. "      
  1302.  X%,YS%:
  1303.  vplot%,X%,YF%
  1304.       column%+=1 
  1305.         
  1306. draw_line
  1307.  x0%+x1%*16,y0%-(line%-1)*36-4
  1308.  "OS_WriteN",TextPtr%,chars%
  1309. update_pane(wi%,x%,y%,w%,h%,xs%,ys%)
  1310. newquery%=!block%
  1311.  wi%=queryW% 
  1312.  newquery%<>oldquery% 
  1313. shut_window(oldquery%):oldquery%=newquery%
  1314. &8!paneblock%=wi%:
  1315.  "Wimp_GetWindowState",,paneblock%
  1316. paneblock%!4=block%!4+x%
  1317. (!paneblock%!12=paneblock%!4+w%
  1318. paneblock%!16=block%!16-y%
  1319. *!paneblock%!8=paneblock%!16-h%
  1320. +'paneblock%!20=xs%:paneblock%!24=ys%
  1321. ,)paneblock%!28=block%!28:block%!28=wi%
  1322.  "Wimp_OpenWindow",,paneblock%
  1323.  "Wimp_OpenWindow",,block%
  1324.  up_pend% 
  1325.  up_pend%=
  1326.  "Wimp_GetWindowState",,block%
  1327.  (block%!32 
  1328.  (1<<18)) 
  1329.  up_pend%=
  1330. update_pane(wi%,x%,y%,w%,h%,xs%,ys%)
  1331.  wi%=titleW% 
  1332. close_window(wi%):
  1333. open_window(wi%)
  1334.  Menu handling -------------------------------------------------------
  1335. make_menus
  1336. fieldM%=
  1337. create_menu(menu_ptr%,"Field,Create index... ^J,#14,Global changes... ^G,Link to table... ^L,Combine fields...,Start editing ^S,Remove object   ,#14!saveW%,Save as CSV!saveW%,Undo changes,Compact sequence")
  1338. :8SaveOb%=
  1339. menu_text(fieldM%,7):$SaveOb%="Save object"
  1340. ;fAnalyseFunc%=
  1341. menu_text(fieldM%,1):CalcFunc%=
  1342. menu_text(fieldM%,4):RemoveOb%=
  1343. menu_text(fieldM%,6)
  1344. <`validateM%=
  1345. create_menu(menu_ptr%,"Validation,Create table...,~Display table,Show files ^Q")
  1346. =fsubfilenameM%=
  1347. create_menu(menu_ptr%,"Subfile name:,^20"):Subfilename%=
  1348. menu_text(subfilenameM%,0)
  1349. >jrenameM%=
  1350. create_menu(menu_ptr%,"New name:,^255"):NewName%=
  1351. menu_text(renameM%,0):$NewName%="!NewName"
  1352. miscM%=
  1353. create_menu(menu_ptr%,"Miscellaneous,Move/delete...,Set passwords...,Field colours...,Edit template ^E,Name subfile>subfilenameM%,Rename database>renameM%")
  1354. @hdelimiterM%=
  1355. create_menu(menu_ptr%,"Separator,Comma,TAB,CR,_LF,^2"):Delim%=
  1356. menu_text(delimiterM%,4)
  1357. AzterminatorM%=
  1358. create_menu(menu_ptr%,"Terminator,CR,LF,LF CR,CR LF,CR CR,_LF LF,^2"):Termin%=
  1359. menu_text(terminatorM%,6)
  1360. B~scrolltermM%=
  1361. create_menu(menu_ptr%,"Scroll terminator,Semicolon,Comma,TAB,_Space,^1"):Scrterm%=
  1362. menu_text(scrolltermM%,4)
  1363. string$="Print,Create report... Print,Show resources ^R,Show jobs done ^P,Options... ^Print,Save query!saveW%,~Numeric fields... ^N,Extra calculations... ^
  1364. N,~Save selection!saveW%,~Clear selection ^Z,~Display selection!,Select all ^A"
  1365. D+printM%=
  1366. create_menu(menu_ptr%,string$)
  1367. EEcsvM%=
  1368. create_menu(menu_ptr%,"CSV files,Export... ^X,Options...")
  1369. FSindexM%=
  1370. create_menu(menu_ptr%,"Index,Show details... ^K,Delete,Show files ^I")
  1371. string$="Powerbase,_Information...,*Field:1234567>fieldM%,Print>printM%,Validation!validateM%,Index!indexM%,Miscellaneous>miscM%,Show keypad Tab,~Export selected!saveW%,Export subset...,Copy as!saveW%,CSV files>csvM%,_Undo changes,Help"
  1372. HImainM%=
  1373. create_menu(menu_ptr%,string$):Fieldpos%=
  1374. menu_text(mainM%,1)
  1375. indextreeM%=
  1376. create_menu(menu_ptr%,"Print index,All subfiles,Current subfile,Symmetrical,_Root first,Totals only,Complete")
  1377. tick(indextreeM%,1,
  1378. tick(indextreeM%,2,
  1379. utilityM%=
  1380. create_menu(menu_ptr%,"Utilities,~New primary key...,~Adjust format...,~New record format...,~Merge databases...,~Change length>sizeW%,~Balance index ^B,~Print index>indextreeM%,~Print field data,~Find duplicates,~Merge commands...")
  1381. LAUtil1%=
  1382. menu_text(utilityM%,1):Util2%=
  1383. menu_text(utilityM%,2)
  1384. iconbarM%=
  1385. create_menu(menu_ptr%,"\Powerbase,_Information>infoW%,New database!saveW%,*Utilities>utilityM%,~Close database,~Rename database>renameM%,Preferences...,_Help,Quit")
  1386. designM%=
  1387. create_menu(menu_ptr%,"New database,Create field...,Fields created,_Default database,Save form file!saveW%,Database size>sizeW%,_Primary key...,Grid>gridW%,Quit design"):DesAction%=
  1388. menu_text(designM%,0)
  1389. tableM%=
  1390. create_menu(menu_ptr%,"Table,Clear,Modify,Print,#15,Undo change,_Undo all,Save!saveW%,Save as CSV!saveW%"):SortTabCol%=
  1391. menu_text(tableM%,3):$SortTabCol%="Sort"
  1392. PHdirectionM%=
  1393. create_menu(menu_ptr%,"Direction,Ascending,Descending")
  1394. listM%=
  1395. create_menu(menu_ptr%,"Report,Save as text!saveW%,Sort   """">directionM%,Shrink list,Discard"):SortTextCol%=
  1396. menu_text(listM%,1)
  1397. RakeystrokeM%=
  1398. create_menu(menu_ptr%,"Keystroke,Assign>fkeyW%,Defaults,Save choices,List keys")
  1399. SBmarkM%=
  1400. create_menu(menu_ptr%,"Marked record,Include,Exclude")
  1401. T`columnM%=
  1402. create_menu(menu_ptr%,"Column no.,^2"):Expcol%=
  1403. menu_text(columnM%,0):$Expcol%="1"
  1404. UzmergecomM%=
  1405. create_menu(menu_ptr%,"Merge command,GetField,GetExpanded>columnM%,NextMatch"):
  1406. tick_one(mergecomM%,0,2,0)
  1407.  --------------- Read validation strings etc -----------------------
  1408. Wrfmenu$()="Editable","Computed","Check-box","External","Keypad button","Extra button","Stamp","Scrollable list"
  1409.  I%=0 
  1410.  L% 30:flist%(I%)=L%:?L%=0
  1411. [)f$="<Pbase$Dir>.Resources.ValStrings"
  1412. vstrings%=100
  1413.  vname$(vstrings%),vtype$(vstrings%),valid%(vstrings%),rvalid%(vstrings%),hvalid%(vstrings%)
  1414.   valid$=
  1415.   C%=
  1416. (valid$)
  1417.  C%>=0 
  1418. cG    P%=
  1419. valid$,":"):vname$(C%)=
  1420. valid$,4,P%-4):valid$=
  1421. valid$,P%+1)
  1422.     vtype$(C%)=
  1423. valid$,1)
  1424.  vtype$(C%)="K" 
  1425. fG      !block%=keypadW%:block%!4=C%-9:
  1426.  "Wimp_GetIconState",,block%
  1427.       valid$=$block%!32
  1428.       
  1429.  valid$=
  1430. valid$,3)
  1431. i        
  1432. j1    
  1433. (valid$)+1:$V%=valid$:valid%(C%)=V%
  1434. k2    
  1435. (valid$)+1:$V%=valid$:rvalid%(C%)=V%
  1436. l5    
  1437. (valid$)+16:$V%=valid$:P%=
  1438. $V%,"Pptr_")
  1439. mK    
  1440.  P%>0 
  1441.  $(V%+P%-1)="Pptr_hand,4,0" 
  1442.  $(V%+
  1443. ($V%))=";Pptr_hand,4,0"
  1444.     hvalid%(C%)=V%  
  1445.  vtype$(C%) 
  1446. pS      
  1447.  "E":fmenu$(0)+=","+vname$(C%):L%=flist%(0):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1448. qS      
  1449.  "C":fmenu$(1)+=","+vname$(C%):L%=flist%(1):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1450. rS      
  1451.  "T":fmenu$(2)+=","+vname$(C%):L%=flist%(2):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1452. sS      
  1453.  "X":fmenu$(3)+=","+vname$(C%):L%=flist%(3):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1454. tS      
  1455.  "K":fmenu$(4)+=","+vname$(C%):L%=flist%(4):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1456. uS      
  1457.  "O":fmenu$(5)+=","+vname$(C%):L%=flist%(5):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1458. vS      
  1459.  "S":fmenu$(6)+=","+vname$(C%):L%=flist%(6):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1460. wS      
  1461.  "L":fmenu$(7)+=","+vname$(C%):L%=flist%(7):N%=?L%:N%+=1:?L%=N%:L%?N%=C%
  1462. x        
  1463. close_file(F)
  1464.  I%=0 
  1465. }IftypeM%(I%)=
  1466. create_menu(menu_ptr%,fmenu$(I%)):
  1467. tick(ftypeM%(I%),0,
  1468. ybar%=144+8*44
  1469. .Dynamicmenus%=menu_ptr%:men_top%=menu_ptr%
  1470. clear_dynamic_menus
  1471. fieldsM%=0
  1472. valtablesM%=0
  1473. userM%=0
  1474. indexesM%=0
  1475. menubuff%=menuindir%
  1476. =Dynamicmenus%
  1477. field_menu(
  1478.  items%,selec%)
  1479.  F%,P%,L%,D$,F$,icptr%,textpointer%,flags%
  1480. items%=-1
  1481. icptr%=
  1482. clear_dynamic_menus
  1483. ;textpointer%=icptr%+(fields%+10)*24+28:$textpointer%=""
  1484. )men_top%=textpointer%+(fields%+10)*17
  1485.  men_top%>men_end% 
  1486.  fatal_err%,"Insufficent room for field menu. Increase menumem% by at least &"+
  1487. ~(men_top%-men_end%)+" bytes"
  1488.  textpointer%>menu_ptr% 
  1489.  menu_ptr%=textpointer%
  1490.  selec%=2 
  1491.  $icptr%="Print order" 
  1492.  $icptr%="Field list"
  1493. Zicptr%?12=7:icptr%?13=2:icptr%?14=7:icptr%?15=0:icptr%!16=270:icptr%!20=44:icptr%!24=0
  1494. icptr%+=28
  1495.  selec% 
  1496.  Include all fields
  1497.  F%=1 
  1498.  fields%
  1499. fieldmenu_item(F%)
  1500.  Queriable fields only
  1501.  F%=1 
  1502.  fields%
  1503.     V%=chartype%(F%):inc%=
  1504.  vtype$(V%) 
  1505.       
  1506.  "K","O":
  1507.  Exclude
  1508. (      
  1509.  "S":inc%=(V%<>59):
  1510.  Not Logo
  1511.       
  1512.  "C","T","L":inc%=
  1513. H      
  1514.  "X":inc%=(V%=36 
  1515.  V%=39 
  1516.  V%=60):
  1517.  Text, Text block & Remote
  1518. 5      
  1519.  "E":inc%=(len%(F%)>0):
  1520.  Not simple labels
  1521.         
  1522. $    
  1523.  inc% 
  1524. fieldmenu_item(F%)
  1525.  Include only highlighted fields
  1526.  I%=1 
  1527. (printorder$)-1 
  1528. $    F%=
  1529. fnum(
  1530. printorder$,I%,2))
  1531. fieldmenu_item(F%)
  1532.  Indexable fields only
  1533.  F%=1 
  1534.  fields%
  1535.     V%=chartype%(F%):inc%=
  1536.  vtype$(V%) 
  1537. (      
  1538.  "S":inc%=(V%<>59):
  1539.  Not Logo
  1540. K      
  1541.  "C":inc%=(V%=6 
  1542.  V%=7):
  1543.  No point indexing auto-updating fields
  1544. 5      
  1545.  "X":inc%=(V%=60):
  1546.  Remote only (pathname)
  1547. 5      
  1548.  "E":inc%=(len%(F%)>0):
  1549.  Not simple labels
  1550.         
  1551. $    
  1552.  inc% 
  1553. fieldmenu_item(F%)
  1554.  F%        
  1555. icptr%!-24=icptr%!-24 
  1556. =Dynamicmenus%
  1557. fieldmenu_item(F%)
  1558. get_icon_cols(mainW%,field%(F%))<>winback%*17 
  1559.   F$=
  1560. "  "+
  1561. (F%)+" ",4)
  1562. 7    
  1563.  F%>MaxFields%+2:F$+=Tag$(F%):flags%=&0B000121
  1564. <    
  1565.  F%=0 
  1566.  F%>MaxFields%:F$+=Tag$(F%):flags%=&08000121
  1567. N    
  1568. text(mainW%,desc%(F%))="":F$+="<Blank> "+Tag$(F%):flags%=&07000121
  1569. 5    D$=
  1570. text(mainW%,desc%(F%)),7)+"       ",8)
  1571. (    F$+=D$+Tag$(F%):flags%=&07000121
  1572.   L%=
  1573. ^  !icptr%=0:icptr%!4=-1:icptr%!8=flags%:icptr%!12=textpointer%:icptr%!16=-1:icptr%!20=L%+1
  1574.   $textpointer%=F$
  1575.   textpointer%+=L%+1
  1576.   icptr%+=24
  1577.   items%+=1
  1578. menu_text(menu%,item%)
  1579. ic%=menu%+28+item%*24
  1580.  ((ic%!8) 
  1581.  &100)=0 
  1582. =ic%+12 
  1583. =ic%!12
  1584. create_menu(
  1585.  menu%,list$)
  1586.  start%,choice$,title$,entries%,item%,P%,Q%,S%,shaded%,width%,L%,LL%,set8%,M$
  1587. start%=menu%
  1588. list$,1)="\" 
  1589.  leftmenu%=
  1590.  list$=
  1591. list$,2)
  1592. list$,",")
  1593. $title$=
  1594. list$,P%-1):L%=
  1595. (title$)
  1596.  L%>12 
  1597. J  !menu%=buff%:$buff%=title$:buff%+=L%+1:menu%!4=-1:menu%!8=L%:set8%=
  1598.  $menu%=title$
  1599. width%=L%:M$=title$
  1600. menu%?12=7:menu%?13=2
  1601. menu%?14=7:menu%?15=0
  1602. *menu%!16=width%:menu%!20=44:menu%!24=0
  1603. item%=menu%+28
  1604. list$+=","
  1605. entries%=0
  1606.   LL%=0
  1607.   Q%=P%+1
  1608.   P%=
  1609. list$,",",Q%)
  1610.  P%>0 
  1611.     !item%=0:shaded%=0
  1612.      choice$=
  1613. list$,Q%,P%-Q%)
  1614.     S%=
  1615. choice$,"!")
  1616. 5    
  1617.  S%>0 
  1618.  ?item%=?item% 
  1619. choice$,S%,1)=">"
  1620.     S%=
  1621. choice$,">")
  1622.  S%=0 
  1623.       item%!4=-1
  1624.       
  1625.       S$=
  1626. choice$,S%+1)
  1627. .      
  1628.  S$<>"" 
  1629.  item%!4=
  1630. (S$) 
  1631.  item%!4=1
  1632.        choice$=
  1633. choice$,S%-1)
  1634.         
  1635. choice$,1) 
  1636. 3      
  1637.  "~":choice$=
  1638. choice$,2):shaded%=(1<<22)
  1639. 5      
  1640.  "_":choice$=
  1641. choice$,2):?item%=?item% 
  1642. F      
  1643.  "*":choice$=
  1644. choice$,2):?item%=?item% 
  1645.  16:shaded%=(1<<22)
  1646. -      
  1647.  "#":LL%=
  1648. choice$,2)):choice$=""
  1649. D      
  1650.  "^":LL%=
  1651. choice$,2)):choice$="":?item%=?item% 
  1652.  (1<<2)
  1653.         
  1654. C    
  1655.  set8% 
  1656.  !item%=!item% 
  1657.  (1<<8):set8%=
  1658.  Indirected title
  1659.     L%=
  1660. (choice$)+1
  1661. *    
  1662.  L%>width% 
  1663.  width%=L%:M$=choice$
  1664.  LL%>0 
  1665.  L%=LL%+1
  1666.  L%>13 
  1667.  LL%>0 
  1668. I      item%!12=buff%:$buff%=choice$:buff%+=L%:item%!16=-1:item%!20=L%
  1669.       item%!8=&7000121
  1670.       
  1671.       $(item%+12)=choice$
  1672.       item%!8=&7000021
  1673.         
  1674. !    item%!8=item%!8 
  1675.  shaded%
  1676.     item%+=24
  1677.     entries%+=1
  1678.  P%=0
  1679. item%!-24=item%!-24 
  1680. menu%=item%
  1681. start%!16=
  1682. string_width(M$)
  1683. =start%
  1684. tick(menu%,item%,on%)
  1685. item%=menu%+28+item%*24
  1686.  on% 
  1687. :?item%=?item% 
  1688. :?item%=?item% 
  1689. tick_one(menu%,first%,last%,item%)
  1690.  I%=first% 
  1691.  last%
  1692. tick(menu%,I%,(I%=item%))
  1693. ticked(menu%,item%)
  1694. item%=menu%+28+item%*24
  1695.  (?item% 
  1696. lit(menu%,item%,on%)
  1697. item%=menu%+28+item%*24
  1698.  on% 
  1699. : item%!8=item%!8 
  1700.  (1<<22)
  1701. : item%!8=item%!8 
  1702.  (1<<22)
  1703. lit(menu%,item%)
  1704. item%=menu%+28+item%*24
  1705.  (item%!8 
  1706.  (1<<22)) 
  1707. show_menu(menu%,x%,y%)
  1708. 2)menuhandle%=menu%:menux%=x%:menuy%=y%
  1709.  "Wimp_CreateMenu",,menuhandle%,x%,y%
  1710. show_pop_up_menu(menu%,wi%,ic%)
  1711.  x%,y%,vxmin%,vymax%,scrollx%,scrolly%
  1712. 80!block%=wi%:
  1713.  "Wimp_GetWindowState",,block%
  1714. 9Jvxmin%=block%!4:vymax%=block%!16:scrollx%=block%!20:scrolly%=block%!24
  1715. :;!block%=wi%:block%!4=ic%:
  1716.  "Wimp_GetIconState",,block%
  1717. ;=x%=block%!16-scrollx%+vxmin%:y%=block%!20-scrolly%+vymax%
  1718. <)menuhandle%=menu%:menux%=x%:menuy%=y%
  1719.  "Wimp_CreateMenu",,menu%,x%,y%
  1720. show_user_menu(buff%,field%,button%)
  1721.  I%,ptr%,blocksize%,menu$,F,items%,P%,m$,forbidden$,d%
  1722. whandle%=wi%:icon%=ic%
  1723. forbidden$=" $&%@\^:.#*|"
  1724. menufield%=
  1725. (Tag$(field%))
  1726.  menufield%=0 
  1727.  Tag$(field%)<>"" 
  1728.  menufield%+=1
  1729. H)    
  1730.  Tag$(menufield%)=Tag$(field%)  
  1731.  menufield%=field%-1
  1732. m$=Tag$(menufield%)
  1733.  I%=1 
  1734.   P%=
  1735. forbidden$,
  1736. m$,I%,1))
  1737.  P%>0 
  1738. m$,I%,1)="_" 
  1739. m$+="Menu"
  1740.  "OS_File",5,$database%+".Menus."+m$ 
  1741.  d%=0 
  1742.  "OS_File",5,$database%+"."+m$ 
  1743.  d%=1 
  1744. V*    
  1745.  "OS_File",8,$database%+".Menus"
  1746. WK    
  1747.  "OS_CLI","Rename "+$database%+"."+m$+" "+$database%+".Menus."+m$
  1748. ($database%+".Menus."+m$)
  1749.  F=0 
  1750. softerror(m$+","+$database%,152):
  1751. #F>255 
  1752. close_file(F):
  1753. softerror(m$,151):
  1754. title$=
  1755.  title$="UserMenu" 
  1756.  button%=1 
  1757. close_file(F):
  1758.  "OS_CLI","Filer_Run "+$database%+".Menus."+m$:
  1759. menu$=title$+","
  1760.   choice$=
  1761.   menu$+=choice$+","
  1762. close_file(F)
  1763. menu$=
  1764. menu$)
  1765.   P%=
  1766. menu$,",",P%+1)
  1767.  P%>0 
  1768.  items%+=1
  1769.  P%=0
  1770. blocksize%=items%*24+28
  1771. k"menu_ptr%=
  1772. clear_dynamic_menus
  1773. l(userM%=
  1774. create_menu(menu_ptr%,menu$)
  1775. show_pop_up_menu(userM%,mainW%,field%(field%))
  1776.  Icon handling -------------------------------------------------------
  1777. create_icon(left%,whandle%,xmin%,ymin%,width%,height%,iconflags%,text$,d1%,d2%,d3%)
  1778.  handle%
  1779. block%!0=whandle%
  1780. u!block%!4=xmin%:block%!8=ymin%
  1781. v2block%!12=xmin%+width%:block%!16=ymin%+height%
  1782. block%!20=iconflags%
  1783.  d1%=0 
  1784.   $(block%+24)=text$
  1785.   block%!24=d1%
  1786.   block%!28=d2%
  1787.   block%!32=d3%
  1788.  "Wimp_CreateIcon",left%,block% 
  1789.  handle%
  1790. =handle%
  1791. string_width(S$)
  1792.  Desktopfont%=0 
  1793.   W%=
  1794. (S$)*16+8
  1795.  "Wimp_TextOp",1,S$,0 
  1796.   W%+=16
  1797. guess_width(chars%,type%,width%)
  1798.  dontalter%
  1799.  chars%=0 
  1800.  type% 
  1801.  2:S$=
  1802. chars%,"M")
  1803.  4:S$="N"
  1804.  chars% 
  1805. 1    
  1806.  8:S$="88"+$datesep%+"88"+$datesep%+"88"
  1807. 4    
  1808.  10:S$="88"+$datesep%+"88"+$datesep%+"8888"
  1809. chars%,"8")
  1810.  3,6,46,47,54,56,57,74,75,77,78,79:S$=
  1811. chars%,"8")
  1812.  8,48,68:S$="88"+$timesep%+"88"+$timesep%+"88"
  1813.  49,69:S$="Wed,09 Aug,1998"
  1814.  50,70:S$="88"+$datesep%+"88"+$datesep%+"88"
  1815.  51,71:S$="88"+$datesep%+"88"+$datesep%+"8888"
  1816.  52,58,72:S$="Wed,09 Aug 1998.88:88:88"
  1817.  53,55,73,76:S$="Wed"
  1818.  0,1,7,63,64,65,66,67:S$=
  1819. chars%,"a")
  1820. :dontalter%=
  1821.  dontalter% 
  1822.  Desktopfont%=0 
  1823.     width%=chars%*16+16 
  1824. "    
  1825.  width%=
  1826. string_width(S$)
  1827.  type% 
  1828. "      
  1829.  64,65,66,67:width%+=42
  1830.         
  1831. =width%
  1832. redraw_icon(wi%,ic%)
  1833. !block%=wi%:block%!4=ic%
  1834. block%!8=0:block%!12=0
  1835.  "Wimp_SetIconState",,block%
  1836. *block%!8=0:block%!12=wi%:block%!16=ic%
  1837. shade(wi%,ic%,on%)
  1838. icon_bit(22,wi%,ic%,on%)
  1839. icon_bit(bit%,wi%,ic%,on%)
  1840. !block%=wi%
  1841. block%!4=ic%
  1842.  on% 
  1843. :block%!8=0:block%!12=1<<bit%
  1844. :block%!8=1<<bit%:block%!12=1<<bit%
  1845.  "Wimp_SetIconState",,block%
  1846. select(wi%,ic%)
  1847. !block%=wi%:block%!4=ic%
  1848. "block%!8=1<<21:block%!12=1<<21
  1849.  "Wimp_SetIconState",,block%
  1850. deselect(wi%,ic%)
  1851. !block%=wi%:block%!4=ic%
  1852.  block%!8=0:block%!12=(1<<21)
  1853.  "Wimp_SetIconState",,block%
  1854. invert(wi%,ic%)
  1855. !block%=wi%:block%!4=ic%
  1856.  block%!8=(1<<21):block%!12=0
  1857.  "Wimp_SetIconState",,block%
  1858. set_icon(wi%,ic%,on%)
  1859.  on% 
  1860. select(wi%,ic%) 
  1861. deselect(wi%,ic%)
  1862. selected(wi%,ic%)
  1863. !block%=wi%:block%!4=ic%
  1864.  "Wimp_GetIconState",,block%
  1865. =((block%!24) 
  1866.  (1<<21))>0
  1867. shaded(wi%,ic%)
  1868. !block%=wi%:block%!4=ic%
  1869.  "Wimp_GetIconState",,block%
  1870. =((block%!24) 
  1871.  (1<<22))>0
  1872. selected_esg(wi%,esg%)
  1873.  "Wimp_WhichIcon",wi%,block%,&003F0000,&00200000+(esg%<<16)
  1874. =!block%
  1875. next_writable(wi%,ic%,d%,r%,wi2%,ic2%)
  1876.  P%,E%,next%
  1877.  "Wimp_WhichIcon",wi%,block%,&00C0E000,(14<<12)
  1878.   E%+=4
  1879.  block%!E%=-1
  1880.  block%!P%<>ic% 
  1881.  P%<E%
  1882.   P%+=4
  1883.  P%=E% 
  1884.  P%-=4
  1885.  r%=1 
  1886.  P%+4=E% 
  1887.  wi2%=0 
  1888.  r%=1 
  1889.  P%+4=E% 
  1890.  wi%=wi2%:next%=ic2%
  1891.  0:P%=E%
  1892.  2:P%=-4
  1893. :P%+=4*d%
  1894.  wi2%>0 
  1895.  wi%=wi2%:next%=ic2% 
  1896.  next%=!block%
  1897.  wi2%>0 
  1898.  wi%=wi2%:next%=ic2% 
  1899.  next%=block%!(E%-4)
  1900. :next%=block%!P%
  1901. set_caret(0,wi%,next%)
  1902. text(wi%,ic%)
  1903. !block%=wi%:block%!4=ic%
  1904.  "Wimp_GetIconState",,block%
  1905. =block%!28
  1906. val(wi%,ic%)
  1907. !block%=wi%:block%!4=ic%
  1908.  "Wimp_GetIconState",,block%
  1909. =block%!32
  1910. text_length(wi%,ic%)
  1911. !block%=wi%:block%!4=ic%
  1912.  "Wimp_GetIconState",,block%
  1913. ($(block%!28))
  1914. buffer_length(wi%,ic%)
  1915. !block%=wi%:block%!4=ic%
  1916.  "Wimp_GetIconState",,block%
  1917. =block%!36-1
  1918. set_caret(pos%,wi%,ic%)
  1919. 0!block%=wi%:
  1920.  "Wimp_GetWindowState",,block%
  1921.  ((block%?34) 
  1922.  1)=1 
  1923.  ic%=-1 
  1924. *    
  1925.  "Wimp_SetCaretPosition",wi%,ic%
  1926.         
  1927. -    
  1928.  pos%=0 
  1929.  pos%=
  1930. text_length(wi%,ic%)
  1931. 6    
  1932.  "Wimp_SetCaretPosition",wi%,ic%,0,0,-1,pos%
  1933. limit_actions(off%,multi%)
  1934.  multi% 
  1935.  12,14,15,16,17,19,20,21,-1
  1936. shade(keypadW%,ic%,off%)
  1937.  buttonfield%(0,ic%)>0 
  1938. shade(mainW%,field%(buttonfield%(0,ic%)),off%)
  1939.  ic%=-1
  1940. lit(fieldM%,0,off%)
  1941. lit(fieldM%,2,off%)
  1942. identify_field(ic%)
  1943. /.Fieldnumber%=0:Fieldname$="":TextLength%=0
  1944.  (ic% 
  1945.  2)=1 
  1946. 1!  !block%=mainW%:block%!4=ic%
  1947.  "Wimp_GetIconState",,block%
  1948.   TextLength%=block%!36-1
  1949.   Fieldnumber%=(ic%+1) 
  1950. 53  Fieldname$=$
  1951. text(mainW%,desc%(Fieldnumber%))
  1952.  Fieldname$="" 
  1953.  Fieldname$=Tag$(Fieldnumber%)
  1954. selected(prefsW%,21) 
  1955. 8$    
  1956.  chartype%(Fieldnumber%) 
  1957. 9&      
  1958.  2,4:
  1959.  "OS_Byte",202,0,239
  1960. :#      
  1961.  "OS_Byte",202,16,111
  1962. ;        
  1963.  "OS_Byte",118
  1964. first_writable
  1965.  I%+=1
  1966.  (vtype$(chartype%(I%))="E" 
  1967.  len%(I%)>0) 
  1968.  I%>fields%
  1969.  I%>fields% 
  1970.  design%=
  1971.  fatal_err%,
  1972. msg("Err150") 
  1973. last_writable
  1974.  I%,V%,V$
  1975. I%=fields%+1
  1976. K9  I%-=1:V%=chartype%(I%):V$=vtype$(V%):ic%=field%(F%)
  1977.  I%=1 
  1978.  ((V$="E" 
  1979.  len%(I%)>0) 
  1980.  V$="L")
  1981.  V$<>"E" 
  1982.  V$<>"L" 
  1983.  I%=0
  1984.  Mouse_click processing ----------------------------------------------
  1985. mouse(x%,y%,b%,wi%,ic%)
  1986.  T%,S%,window%,icon%
  1987. OLE%=0:cell$=""
  1988. oldx%=x%:oldy%=y%
  1989. VCblock%!0=x%:block%!4=y%:block%!8=b%:block%!12=wi%:block%!16=ic%
  1990.  T%=0 
  1991.  LastTable%
  1992.  wi%=tableW%(T%) 
  1993.  Tablenumber%=T%
  1994. Z!Scroller%=
  1995. scroller_num2(wi%)
  1996.  "Wimp_GetCaretPosition",,block%
  1997. \"window%=!block%:icon%=block%!4
  1998.  window% 
  1999.  mainW%,scrollerW%(Scroller%),queryW%,helpW%,changeW%,moveW%:oldwindow%=window%:oldicon%=icon%
  2000.  window%<>tableW%(Tablenumber%) 
  2001.  oldwindow%=0:oldicon%=0
  2002.  wi% 
  2003. iconbar_click
  2004.  infoW%:
  2005. info_click(ic%,b%)
  2006.  accessW%:accessbutton%=ic%
  2007.  aclW%:
  2008.  mainW%:
  2009. main_click(wi%,ic%,b%)
  2010.  keypadW%:
  2011. keypad_click(wi%,ic%,b%)
  2012.  saveW%,savesubW%:
  2013. save_click(wi%,ic%,b%)
  2014.  keyW%:
  2015. key_click(wi%,ic%,b%)
  2016.  tabcreateW%:
  2017. tabcreate_click(wi%,ic%,b%)
  2018.  scrollW%:
  2019. scroll_click
  2020.  linkW%:
  2021. link_to_table(wi%,ic%,b%)
  2022.  passW%:
  2023. passwords(x%,wi%,ic%,b%)
  2024.  printW%:
  2025. print_click(wi%,printerW%,ic%,b%)
  2026.  printerW%:
  2027. printer_click(printW%,wi%,ic%,b%)
  2028.  matchW%:
  2029. match_click(wi%,ic%,b%)
  2030.  createW%:
  2031. create_click(wi%,ic%,b%,icon%)
  2032.  tableW%(Tablenumber%):
  2033. table_click(Tablenumber%)
  2034.  scrollerW%(Scroller%):
  2035. scroller_click(wi%,ic%,b%,Scroller%)
  2036.  changeW%:
  2037. change_click(wi%,ic%,b%)
  2038.  moveW%:
  2039. move_click(wi%,ic%,b%)
  2040.  listW%:
  2041. list_click(x%,y%,b%,wi%)
  2042.  colW%:
  2043. set_colours(wi%,ic%,b%)
  2044.  calcW%:
  2045. calc_formula(OldField%,wi%,ic%,b%,$CalcForm%)
  2046.  mergeW%:
  2047. merge_click(wi%,ic%)
  2048.  sizeW%:
  2049. size_click(wi%,ic%,b%)
  2050.  csvW%:
  2051. csv_click(wi%,ic%,b%)
  2052.  fkeyW%:
  2053. fkey_click(wi%,ic%,b%)
  2054.  prefsW%:
  2055. prefs_click(wi%,ic%,b%)
  2056.  queryW%:
  2057. query_click(wi%,ic%,b%)
  2058.  helpW%:
  2059. help_click(wi%,ic%,b%)
  2060.  reformW%:
  2061. reform_click(wi%,ic%,b%)
  2062.  mergebaseW%:
  2063. mergebase_click(wi%,ic%,b%)
  2064.  filterW%:
  2065. filter_click(wi%,ic%,b%)
  2066.  searchW%:
  2067. search_click(wi%,ic%,b%)
  2068.  gridW%:
  2069. grid_click(wi%,ic%,b%)
  2070.  relateW%:
  2071. val_help
  2072.  markW%:
  2073. mark_click(wi%,ic%,b%)
  2074.  pselectW%:
  2075. close_it(wi%)
  2076.  extracalcW%:
  2077. extra_calcs(wi%,ic%,b%)
  2078.  inputW%:
  2079. input_click(wi%,ic%)
  2080.  miscW%:
  2081. misc_click(wi%,ic%)
  2082.  titleW%:HasTitle%=2:
  2083. close_window(wi%)
  2084.  mergecomW%:
  2085. mergecom_click(wi%,ic%,b%)
  2086.  bannerW%,numscrollW%:
  2087.  ### No action on this ###
  2088.  customise% 
  2089. (libfunc$+"_click(wi%,ic%,b%)")
  2090.  wi%<>matchW% 
  2091.  wi%<>mainW% 
  2092. mergecom_click(wi%,ic%,b%)
  2093. "fieldsM%=
  2094. field_menu(items%,1)
  2095.  ic% 
  2096.  1,2:
  2097.  (b% 
  2098.  %111)=4 
  2099.  z%=1 
  2100.  (b% 
  2101.  %111)=1 
  2102.  z%=-1
  2103.  ic%=2 
  2104.  mergefield%+=z% 
  2105.  mergefield%-=z%
  2106.  mergefield%>fields% 
  2107.  mergefield%=1
  2108.  mergefield%<1 
  2109.  mergefield%=fields%
  2110. tick_one(fieldsM%,0,fields%-1,mergefield%-1)
  2111. show_pop_up_menu(fieldsM%,wi%,ic%)
  2112.   fieldfunc$="mergecom"
  2113. show_pop_up_menu(mergecomM%,wi%,ic%)
  2114. close_window(wi%)
  2115.  (b% 
  2116.  %11110000)>0 
  2117. ;    Start%=
  2118. text(wi%,5):End%=Start%+
  2119. text_length(wi%,5)
  2120. .    Filename$=Tag$(mergefield%):Type%=&fff
  2121. init_drag(wi%,ic%,5)
  2122. set_mergecom_icons
  2123. set_mergecom_icons
  2124.  shade%
  2125. text(mergecomW%,3)=Tag$(mergefield%)
  2126. redraw_icon(mergecomW%,3)
  2127. convert_to_DDF(mergefield%)
  2128. <shade%=
  2129.  (link$(mergefield%)="" 
  2130. ticked(mergecomM%,1))
  2131. shade(mergecomW%,5,shade%)
  2132. shade(mergecomW%,9,shade%)
  2133. convert_to_DDF(F%)
  2134. ticked(mergecomM%,0):S$="{merge "":Powerbase GetField "+Tag$(F%)+"""}"
  2135. ticked(mergecomM%,1):S$="{merge "":Powerbase GetExpanded "+Tag$(F%)
  2136. ($Expcol%)>1 
  2137.  S$+=","+$Expcol%
  2138.   S$+="""}"
  2139. ticked(mergecomM%,2):S$="{merge "":Powerbase NextMatch""}"
  2140. text(mergecomW%,5)=S$:
  2141. redraw_icon(mergecomW%,5)
  2142. misc_click(wi%,ic%)
  2143.  ic% 
  2144.  28,29,30,31,32,33:file%=ic%-28:
  2145. set_subfile(file%)
  2146.  filemem%(file%,key%)>=0 
  2147. 5    addr=filemem%(file%,key%):
  2148. display(key%,addr)
  2149. "    
  2150.  addr=
  2151. moveto(key%,top,1)
  2152.  "Wimp_StartTask","Resources:$.Apps.!Help"
  2153. print_init("W"):Lmargin%=1:LenLine%=40
  2154. end_line
  2155. store_string(
  2156. store_string("Database usage",1,
  2157. store_string(
  2158. pad("Subfile",20)+"Records   Updated",1,
  2159.  I%=0 
  2160. (    
  2161. store_string($Subfile%(I%),1,
  2162. 6    
  2163. store_string(
  2164. padL($
  2165. text(wi%,I%+22),6),22,
  2166. &    
  2167. store_string($Date%(I%),30,
  2168. store_string("Total records used",1,
  2169. store_string(
  2170. padL($used%,6),22,
  2171. store_string("Records available",1,
  2172. store_string(
  2173. padL($Records%,6),22,
  2174. store_string("Percentage used",1,
  2175. store_string(
  2176. padL($percent%,6),23,
  2177. .  $SaveName%=$database%+".PrintJobs.Stats"
  2178. /  $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  2179.   savefunc$="Save as text"
  2180. shade(saveW%,4,
  2181. deselect(saveW%,4)      
  2182. show_menu(saveW%,x%-64,y%+200)
  2183.   Listed%=
  2184. close_window(wi%)
  2185. input_click(wi%,ic%)
  2186.  ic% 
  2187.  $Params%<>"" 
  2188.  input%=
  2189.  3:cancel%=
  2190. info_click(ic%,b%)
  2191. b%=(b% 
  2192.  %111)
  2193.  ic% 
  2194. :    
  2195.  "XOS_ReadVarVal","Alias$URLOpen_HTTP",,-1 
  2196. @    
  2197.  E%=0 
  2198. softerror("web browser",198) 
  2199. internet(Web$)
  2200. <    
  2201.  "XOS_ReadVarVal","Alias$URLOpen_mailto",,-1 
  2202. D    
  2203.  E%=0 
  2204. softerror("email program",198) 
  2205. internet(Email$)
  2206. 9    
  2207.  "Wimp_StartTask","Resources:$.Apps.!Help"
  2208.  b%=4 
  2209.  "Wimp_CreateMenu",,-1
  2210. internet(url$)
  2211.  var$
  2212. url$,"@")>0:var$="Open_mailto"
  2213. url$,7)<>"mailto:" 
  2214.  url$="mailto:"+url$
  2215. url$,7)="http://":var$="Open_HTTP"
  2216. url$,3)="www":url$="http://"+url$:var$="Open_HTTP"
  2217. :url$="http://www."+url$:var$="Open_HTTP"
  2218. Run_It$="URL"+var$+" "+url$
  2219. -block%!0=256:block%!12=0:block%!16=&4AF80
  2220. (url$)<224 
  2221.   $(block%+20)=url$+
  2222. B  SHurlptr%=
  2223. extend_named_sliding_block(urlanchor%,SHclaim%)  
  2224. :  block%!20=0:block%!24=SHurlptr%:$SHurlptr%=url$+
  2225.  "Wimp_SendMessage",18,block%,0:my_ref%=block%!8
  2226. grid_click(wi%,ic%,b%)
  2227.  z%,space%,snap%,F
  2228. b%=(b% 
  2229.  %111)
  2230.  1,4:
  2231.  b%=4 
  2232.  z%=1 
  2233.  z%=-1
  2234.  ic% 
  2235. &    
  2236.  0:showgrid%=
  2237. selected(wi%,0)
  2238. !(      
  2239.  4:gridcol%=(gridcol%+1) 
  2240. "4      
  2241.  1:gridcol%-=1:
  2242.  gridcol%<0 
  2243.  gridcol%=15
  2244. #        
  2245. $-    
  2246. set_icon_cols(wi%,ic%,7+gridcol%*16)
  2247.  3,4:
  2248. &!    
  2249. selected_esg(wi%,1) 
  2250.       
  2251.  3:plot%=5
  2252.       
  2253.  4:plot%=21
  2254. )        
  2255. *D    
  2256.  5:snapgrid%=
  2257. selected(wi%,5):
  2258. shade(createW%,49,snapgrid%)
  2259. +%    
  2260.  "Wimp_CreateMenu",,-1
  2261.  11,12:
  2262. -@    space%=
  2263. ($Gridspace%):space%+=(2*z%)*((ic%=11)-(ic%=12))
  2264. .>    
  2265.  space%>0 
  2266.  $Gridspace%=
  2267. (space%):
  2268. redraw_icon(wi%,8)
  2269.  13,14:
  2270. 0=    snap%=
  2271. ($Gridsnap%):snap%+=(2*z%)*((ic%=13)-(ic%=14))
  2272. 1;    
  2273.  snap%>0 
  2274.  $Gridsnap%=
  2275. (snap%):
  2276. redraw_icon(wi%,9)
  2277. 3-    F=
  2278. ("<Pbase$Dir>.Resources.GridOpts")
  2279. 4.    
  2280. #F,showgrid%,snapgrid%,gridcol%,plot%
  2281. 5"    
  2282. #F,$Gridspace%,$Gridsnap%
  2283. close_file(F)
  2284. grid_opts
  2285.  ic%>=0 
  2286. redraw(mainW%)
  2287. grid_opts
  2288.  F,d$
  2289. (-1) 
  2290.  d$="Initial" 
  2291.  d$="Resources"
  2292. ("<Pbase$Dir>."+d$+".GridOpts")
  2293. #F,showgrid%,snapgrid%,gridcol%,plot%
  2294. #F,$Gridspace%,$Gridsnap%
  2295. close_file(F)
  2296. set_icon(gridW%,0,showgrid%)
  2297. set_icon(gridW%,5,snapgrid%)
  2298. set_icon(gridW%,3,plot%=5)
  2299. set_icon(gridW%,4,plot%=21)
  2300. set_icon_cols(gridW%,2,7+gridcol%*16)
  2301. filter_click(wi%,ic%,b%)
  2302. b%=(b% 
  2303.  %111)
  2304.  ic% 
  2305. Q'    
  2306.  $Query%<>"" 
  2307.  MarkedRecs%>0 
  2308. R9      $
  2309. text(wi%,5)="":
  2310. redraw_icon(wi%,5):matched%=0
  2311.       Filter$=
  2312. parse
  2313. T4      
  2314. check_record 
  2315.  addr=
  2316. moveto(key%,top,1)
  2317. U        
  2318. deselect(keypadW%,22)
  2319. XF    ic%=field%(buttonfield%(0,22)):
  2320.  ic%>0 
  2321. deselect(mainW%,ic%)
  2322. Y,    
  2323. filter(keypadW%,4,
  2324. ):Filter$="TRUE"
  2325. Z!    
  2326. restore_caret(returnto%)
  2327. [4    
  2328. close_it(wi%):
  2329. restore_caret(returnto%)
  2330. ]3    
  2331. deselect(matchW%,
  2332. selected_esg(matchW%,1))
  2333. select(matchW%,3)
  2334.     Search$=
  2335. parse
  2336. do_it(Search$,-1)
  2337. a5    $
  2338. text(wi%,5)=
  2339. (printed%):
  2340. redraw_icon(wi%,5)
  2341. search_click(wi%,ic%,b%)
  2342.  searchkey%,index$,z%,addr2,oldaddr
  2343. oldaddr=addr
  2344. index$=$
  2345. text(wi%,3)
  2346.  index$<>Index$(searchkey%)
  2347.   searchkey%+=1
  2348. b%=(b% 
  2349.  %111)
  2350.  1,4:
  2351.  b%=4 
  2352.  z%=1 
  2353.  z%=-1
  2354.  ic% 
  2355. s1    SearchKey$=
  2356. stripright($
  2357. text(wi%,1)," ")
  2358. t)    
  2359.  chartype%(KF%(searchkey%,0)) 
  2360.       
  2361.  5,50,51,70,71:
  2362.       
  2363. check_date(KF%(searchkey%,0),SearchKey$,1,date$)=
  2364.  SearchKey$=
  2365. transform_date(KL%(searchkey%),date$) 
  2366.  SearchKey$=""
  2367. w        
  2368. x>    
  2369.  SearchKey$<>"" 
  2370.  addr=
  2371. find(SearchKey$,searchkey%,
  2372.  searchkey%<>key% 
  2373. z,      val$=
  2374. type(key%):kl%=
  2375. (key$(key%))
  2376. {*      addr2=
  2377. search(key$(key%),key%,2)
  2378. |/      
  2379.  addr2<0 
  2380.  addr=oldaddr 
  2381.  addr=addr2
  2382. }        
  2383.  b%=4 
  2384. 3      
  2385. close_it(wi%):
  2386. restore_caret(starthere%)
  2387.       
  2388. set_caret(0,wi%,1)
  2389.         
  2390. )    
  2391.  chartype%(KF%(searchkey%,0)) 
  2392. P      
  2393.  5,50,51,70,71:SearchKey$=
  2394. transform_date(KL%(searchkey%),SearchKey$)
  2395.         
  2396. H    $
  2397. text(wi%,1)=SearchKey$:
  2398. redraw_icon(wi%,1):
  2399. set_caret(0,wi%,1)
  2400. 5    
  2401. close_it(wi%):
  2402. restore_caret(returnto%)
  2403.         
  2404.       searchkey%+=z%
  2405. O      
  2406.  searchkey%>Keys% 
  2407.  searchkey%=0 
  2408.  searchkey%<0 
  2409.  searchkey%=Keys%
  2410. =    
  2411.  Index$(searchkey%)<>"" 
  2412.  hide%?KF%(searchkey%,0)<>1
  2413.         
  2414.       searchkey%-=z%
  2415. U            
  2416.  searchkey%>Keys% 
  2417.  searchkey%=0 
  2418.  searchkey%<0 
  2419.  searchkey%=Keys%
  2420. ?    
  2421.  Index$(searchkey%)<>"" 
  2422.  hide%?KF%(searchkey%,0)<>1  
  2423. text(wi%,3)=Index$(searchkey%):
  2424. redraw_icon(wi%,3)
  2425. reform_click(wi%,ic%,b%)
  2426.  I%,J%,key%
  2427.  ic% 
  2428.  (b% 
  2429.  %11110000)>0 
  2430. 1    $Reformatted%=
  2431. force_pling($Reformatted%)
  2432. '    Filename$=$Reformatted%:Type%=0
  2433. init_drag(wi%,ic%,5)
  2434. 2    
  2435.  $Newform%="" 
  2436.  reformat%=1 
  2437.  reformat%=2
  2438.  1:$Reformatted%="":
  2439. close_window(wi%):
  2440. restore_caret(returnto%)
  2441. do_reformat
  2442. mergebase_click(wi%,ic%,b%)
  2443. text(wi%,4)=
  2444. force_pling($
  2445. text(wi%,4))
  2446. Filename$=$
  2447. text(wi%,4)
  2448.  (b% 
  2449.  %111) 
  2450.  1,4:
  2451.  ic% 
  2452.  (b% 
  2453.  %111)=4 
  2454.       
  2455. Filename$,".")>0 
  2456. 0        mergefiles%=
  2457. save(Filename$,0,0,0)
  2458.         
  2459. softerror("",33)
  2460.       
  2461.         
  2462. E    
  2463. text(wi%,3)="":
  2464. close_it(wi%):
  2465. restore_caret(returnto%)
  2466.  ic%=7 
  2467.  (b% 
  2468.  %11110000)>0 
  2469. 1  Type%=0:mergefiles%=
  2470. init_drag(wi%,ic%,5)
  2471. query_click(wi%,ic%,b%)
  2472.  (b% 
  2473.  %111) 
  2474.  1,4:
  2475.  ic% 
  2476. B    
  2477.  "Wimp_GetCaretPosition",,block%:caretpos%=block%!20
  2478. F    
  2479.  2:$Query%=query$:
  2480. set_caret(0,queryW%,0):
  2481. redraw_icon(wi%,0)
  2482.     $
  2483. text(helpW%,0)=""
  2484.     Match_tag%=Fieldnumber%
  2485. :    
  2486.  Match_tag%>0 
  2487. text(helpW%,0)=Tag$(Match_tag%)
  2488. 5    
  2489. position_window(helpW%,x%+64,y%-300,0,0,0,0)
  2490. 0    
  2491. set_caret(0,helpW%,6):fieldfunc$="help"
  2492. (    
  2493.  6,7,8,9,10,11:
  2494. invert(wi%,ic%)
  2495. prefs_click(wi%,ic%,b%)
  2496. b%=(b% 
  2497.  %111)
  2498.  1,4:
  2499.  ic% 
  2500. &    
  2501.  12:kill%=
  2502. selected(wi%,12)
  2503. Q    
  2504. shade(keypadW%,18,
  2505. selected(wi%,21)):
  2506. val_on_off(
  2507. selected(wi%,21))
  2508. W    
  2509.  27,28,29:
  2510. shade(wi%,25,
  2511. selected(wi%,29)):autosave%=29-
  2512. selected_esg(wi%,2)
  2513. 3    
  2514. set_icon(queryW%,1,
  2515. selected(wi%,30))
  2516. L    
  2517. shade(wi%,32,
  2518. selected(wi%,31)):autobalance%=
  2519. selected(wi%,31)
  2520. +    
  2521.  34:dupwarn%=
  2522. selected(prefsW%,34)
  2523. /    
  2524. (-1) 
  2525.  d$="Initial" 
  2526.  d$="Resources"
  2527. N    
  2528. get_preferences(prefsW%,"<Pbase$Dir>."+d$+".Preference"):
  2529. redraw(wi%)
  2530. selected(wi%,35) 
  2531. 9      
  2532. save_preferences(wi%,$database%+".Preference")
  2533. E      
  2534. save_preferences(wi%,"<Pbase$Dir>.Resources.Preference")
  2535.         
  2536.  b%=4 
  2537. "      $ImpulseApp%=$mergewith%
  2538.       
  2539. close_window(wi%)
  2540.       
  2541.  present%=7 
  2542.          starthere%=
  2543. start_at
  2544. %        
  2545. restore_caret(returnto%)
  2546.       
  2547.         
  2548. 4    
  2549. restore_window(wi%,remember%+winbuff%(4,1))
  2550. L    
  2551.  b%=4 
  2552. close_window(wi%):
  2553. restore_caret(returnto%) 
  2554. redraw(wi%)
  2555. H    
  2556. selected(wi%,ic%) 
  2557.  filemem%(file%,key%)=addr 
  2558.  filemem%()=-1
  2559. )    
  2560. auto_csv(
  2561. selected(wi%,44))
  2562. start_at
  2563.  F%,X%,S$
  2564. S$=$StartHere%
  2565. (S$)>0:F%=
  2566.  S$<>"":F%=
  2567. field(X%,S$,
  2568.  vtype$(chartype%(F%))<>"E" 
  2569. first_writable
  2570. $StartHere%=Tag$(F%)
  2571. =field%(F%)
  2572. fkey_click(wi%,ic%,b%)
  2573.  z%,K$,K%,Z%
  2574. b%=(b% 
  2575.  %111)
  2576.  1,4:
  2577.  (b% 
  2578.  %111)=4 
  2579.  z%=1 
  2580.  z%=-1
  2581.  ic% 
  2582.  4,5:
  2583. #    K$=$Fkeyequiv%:K%=
  2584. K$,2))
  2585.  ic% 
  2586.       
  2587.  4:K%+=z%
  2588.       
  2589.  5:K%-=z%
  2590.         
  2591.  K%=12 
  2592.  K%=0
  2593.  K%<0 
  2594.  K%=11
  2595. )    
  2596.  K%=0 
  2597.  K$="None" 
  2598.  K$="F"+
  2599. *    $Fkeyequiv%=K$:
  2600. redraw_icon(wi%,3)
  2601. #    K$=$Fkeyequiv%:K%=
  2602. K$,2))
  2603.  K%>0 
  2604.       
  2605.  K%>9 
  2606.  K%+=64
  2607. %      
  2608. selected(wi%,1) 
  2609.  K%+=16
  2610. %      
  2611. selected(wi%,2) 
  2612.  K%+=32
  2613.       K%+=384
  2614. >      Z%=
  2615. key_assigned(K%):
  2616.  Z%<>-1 
  2617.  buttonfield%(1,Z%)=0
  2618. "      buttonfield%(1,kpad%)=K%
  2619.       
  2620.  kpad% 
  2621.         
  2622.  13,14,18:
  2623. C        Z%=
  2624. key_assigned(K%+16):
  2625.  Z%<>-1 
  2626.  buttonfield%(1,Z%)=0
  2627. *        buttonfield%(1,kpad%+10)=K%+16
  2628.       
  2629.         
  2630. )    
  2631.  b%=4 
  2632.  "Wimp_CreateMenu",,-1
  2633.  $    
  2634.  "Wimp_CreateMenu",,-1
  2635. change_click(wi%,ic%,b%)
  2636. b%=(b% 
  2637.  %111)
  2638.  ic% 
  2639. +I    
  2640. changes(key%,Menufield%,$
  2641. text(changeW%,0),$
  2642. text(changeW%,1),
  2643.  b%=4 
  2644. close_it(wi%)
  2645. -!    
  2646. restore_caret(returnto%)
  2647. .4    
  2648. close_it(wi%):
  2649. restore_caret(returnto%)
  2650. move_click(wi%,ic%,b%)
  2651. b%=(b% 
  2652.  %111)
  2653.  b%=4 
  2654.  z%=1 
  2655.  b%=1 
  2656.  z%=-1 
  2657.  ic% 
  2658. :#    
  2659. scycle(7,source%,-z%)
  2660. ;"    
  2661. scycle(7,source%,z%)
  2662. <!    
  2663. scycle(8,dest%,-z%)
  2664. =     
  2665. scycle(8,dest%,z%)
  2666. >v    
  2667. shade(wi%,8,
  2668. shade(wi%,12,
  2669. shade(wi%,13,
  2670. shade(wi%,9,
  2671. text(wi%,1)="Move":
  2672. redraw_icon(wi%,1)
  2673. ?x    
  2674. shade(wi%,8,
  2675. shade(wi%,12,
  2676. shade(wi%,13,
  2677. shade(wi%,9,
  2678. text(wi%,1)="Delete":
  2679. redraw_icon(wi%,1)
  2680. @|    
  2681. shade(wi%,8,
  2682. shade(wi%,12,
  2683. shade(wi%,13,
  2684. shade(wi%,9,
  2685. text(wi%,1)="Accumulate":
  2686. redraw_icon(wi%,1)
  2687. save_keys
  2688. CF    
  2689. selected(wi%,5) 
  2690. selected(prefsW%,15) 
  2691.  undo%=1 
  2692.  undo%=2
  2693. D-    
  2694. move_records(key%,source%,dest%,top)
  2695. E     addr=
  2696. moveto(key%,top,1)
  2697. F:    
  2698.  b%=4 
  2699. close_it(wi%):
  2700. restore_caret(starthere%)
  2701.  undo% 
  2702. I       
  2703. softerror("",142)
  2704. J       
  2705. softerror("",143)
  2706.       
  2707. L3      
  2708. load_index($database%+".PrimaryKey",0,
  2709. M#      f$=$database%+".Indexes."
  2710.       
  2711.  Keys%>0 
  2712.         
  2713.  K%=1 
  2714.  Keys%
  2715. P-          
  2716. load_index(f$+Index$(K%),K%,
  2717.         
  2718.       
  2719. S"      
  2720. blob_deleterestore("R")
  2721. T        
  2722. U:    
  2723.  b%=4 
  2724. close_it(wi%):
  2725. restore_caret(starthere%)
  2726. V4    
  2727. close_it(wi%):
  2728. restore_caret(returnto%)
  2729. blob_deleterestore(A$)
  2730.  F,S$,M$
  2731. ($database%+".Deleted")
  2732.  F>0 
  2733.  A$="D" 
  2734. inform("",168,0) 
  2735. inform("",169,0)
  2736.     S$=
  2737. c1      
  2738.  "R":
  2739.  "OS_CLI","Rename "+S$+" "+
  2740. d(      
  2741.  "D":
  2742.  "OS_CLI","Remove "+S$
  2743. e        
  2744. close_it(informW%)
  2745. close_file(F)
  2746.  "OS_CLI","Delete "+$database%+".Deleted"
  2747.  addr=FNmoveto(key%,top,1)
  2748. undo%=0
  2749. scycle(icon%,
  2750.  file%,z%)
  2751. file%+=z%
  2752.  file%<0 
  2753.  file%=5
  2754.  file%=6 
  2755.  file%=0
  2756. text(moveW%,icon%)=$Subfile%(file%)
  2757. redraw_icon(moveW%,icon%)
  2758. csv_click(wi%,ic%,b%)
  2759. b%=(b% 
  2760.  %111)
  2761.  2,4:
  2762.  ic% 
  2763. }2    
  2764. show_pop_up_menu(delimiterM%,wi%,ic%)
  2765. ~3    
  2766. show_pop_up_menu(terminatorM%,wi%,ic%)
  2767. 4    
  2768. show_pop_up_menu(scrolltermM%,wi%,ic%)
  2769.  1,4:
  2770.  ic% 
  2771. ,    
  2772. shade(wi%,4,(
  2773. selected(wi%,1)))
  2774. "    
  2775. text(wi%,9)="Import" 
  2776.       
  2777.  csvfunc$ 
  2778. 7        
  2779.  "ImportMain":
  2780. convert_csv($
  2781. text(wi%,13))
  2782. F        
  2783.  "ImportTable":
  2784. csv_to_table(Tablenumber%,$
  2785. text(wi%,13))
  2786. I        
  2787.  "ImportScroller":
  2788. csv_to_scroller(Scroller%,$
  2789. text(wi%,13))
  2790.       
  2791.         
  2792. %    
  2793.  b%=4 
  2794. close_window(csvW%)
  2795. d    
  2796. restore_window(wi%,remember%+winbuff%(0,1)):
  2797.  b%=4 
  2798. close_window(wi%) 
  2799. redraw(wi%)
  2800. selected(wi%,18) 
  2801. ?      
  2802. save_csv_options("<Pbase$Dir>.Resources.CSVoptions")
  2803. 7      
  2804. save_csv_options($database%+".CSVoptions")
  2805.         
  2806. /    
  2807. (-1) 
  2808.  d$="Initial" 
  2809.  d$="Resources"
  2810. 9    
  2811. get_csv_options("<Pbase$Dir>."+d$+".CSVoptions")
  2812. 7    
  2813. selected(csvW%,24) 
  2814. softerror("",132)
  2815. merge_click(wi%,ic%)
  2816.  ic% 
  2817.  "Impulse_SendMessage",&201,":"+$mergewith%+"."+document$+" Print",,,,printtag%,mytask%
  2818.   merging%=
  2819. :finished%=
  2820.   $mergewith%=$ImpulseApp%
  2821.  "Impulse_SendMessage",&200,":"+$mergewith%+"."+document$+" Edit Off",0,0,0,-1,mytask%
  2822. @  mergenum%=0:$
  2823. text(wi%,7)=
  2824. (mergenum%):
  2825. redraw_icon(wi%,7)
  2826. selected(queryW%,4) 
  2827.  direction%=-1 
  2828.  direction%=1
  2829. 4  addr=
  2830. neighbour(key%,addr,(-direction%+1) 
  2831. selected(mergeW%,12) 
  2832.  addr=
  2833. moveto(key%,addr,direction%) 
  2834.  addr=
  2835. moveto(key%,top,direction%)
  2836.   merging%=
  2837.  "Impulse_SendMessage",&200,":"+$mergewith%+"."+document$+" Edit On",,,,-1,mytask%
  2838. deselect(mergeW%,3)
  2839. close_file(dbasehandle%):
  2840. close_it(wi%)
  2841.   merging%=
  2842.  "Impulse_SendMessage",&200,":"+$mergewith%+"."+document$+" ClearMerge",,,,-1,mytask%
  2843.  "Impulse_SendMessage",&200,":"+$mergewith%+"."+document$+" Edit On",,,,-1,mytask%
  2844. size_click(wi%,ic%,b%)
  2845.  recs$,inc$
  2846.  present%<>7 
  2847.  "Wimp_CreateMenu",,-1:
  2848. 9recs$=
  2849. (RA%):keybase%=SHkeyptr%(0):inc$=
  2850. (keybase%!4)
  2851. b%=(b% 
  2852.  %111)
  2853.  1,4:
  2854.  ic% 
  2855.       
  2856. ($Records%)<=0:
  2857.       
  2858. softerror("",71)
  2859. 0      $Records%=recs$:
  2860. redraw_icon(sizeW%,1)
  2861.       
  2862. ($Increment%)<0
  2863.       
  2864. softerror("",72)
  2865. 3      $Increment%=inc$:
  2866. redraw_icon(sizeW%,3)  
  2867.       
  2868. (      
  2869. change_length(
  2870. ($Records%),
  2871.       
  2872. save_keys
  2873. "      
  2874.  "Wimp_CreateMenu",,-1
  2875.         
  2876. (    $Records%=recs$:$Increment%=inc$
  2877.      
  2878.  "Wimp_CreateMenu",,-1
  2879. table_click(T%)
  2880.  S$,tablefield%
  2881. `NewTab%=(
  2882. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)="
  2883. *extra%=-NewTab%*(Rows%*(TabFields%+1))
  2884. lit(tableM%,1,NewTab% 
  2885.  Modify%)
  2886. $tableM%=table$(T%)
  2887.  ic%>=0 
  2888. (  tablefield%=(ic% 
  2889.  (TabFields%+1))
  2890.  tablefield%=0
  2891.  2047 
  2892.  ic%<Rows%*(TabFields%+1) 
  2893. "    S$=$
  2894. text(tableW%(T%),ic%)
  2895. 1    
  2896. enter_string(S$,oldwindow%,oldicon%)    
  2897.  1024:
  2898.  ic%<Rows%*(TabFields%+1) 
  2899.  Access%=
  2900. <    !block%=tableW%(T%):
  2901.  "Wimp_GetWindowState",,block%
  2902. Q    
  2903.  "Wimp_SetCaretPosition",tableW%(T%),ic%,x%-block%!4+block%!20,y%,-1,-1
  2904. asterisk(
  2905. '  sort_tabcol%=ic% 
  2906.  (TabFields%+1)
  2907.  sort_tabcol%>=0 
  2908. lit(tableM%,3,Access%)
  2909.  NewTab% 
  2910. B      h$=$
  2911. text(tableW%(T%),Rows%*(TabFields%+1)+sort_tabcol%)
  2912. %      $SortTabCol%="Sort "+
  2913. h$,9)
  2914. 7      
  2915.  $SortTabCol%="Sort column "+
  2916. (sort_tabcol%)
  2917.         
  2918. lit(tableM%,3,
  2919. lit(tableM%,7,
  2920. selected(passW%,13))
  2921. lit(tableM%,6,
  2922. selected(passW%,13))
  2923. show_menu(tableM%,x%-64,y%)
  2924.  256:
  2925. invert(wi%,tablefield%+extra%)
  2926. @  field$=
  2927. (tablefield%):
  2928.  tablefield%<10 
  2929.  field$="0"+field$
  2930.   field$+=":"
  2931. selected(wi%,tablefield%+extra%) 
  2932.     printrel$(T%)+=field$
  2933.         
  2934. !    P%=
  2935. printrel$(T%),field$)
  2936. ?    printrel$(T%)=
  2937. printrel$(T%),P%-1)+
  2938. printrel$(T%),P%+3)
  2939. set_icon(printW%,5,(printrel$(T%)<>""))
  2940. enter_string(S$,wi%,
  2941.  ic%)
  2942.  L%,ok%,scroll%,T%,N$
  2943.  wi%=0 
  2944.  wi% 
  2945.  mainW%:
  2946.  chartype%(Fieldnumber%) 
  2947.  0,1,2,3,4,63:ok%=
  2948.  scrollerW%(Scroller%):ok%=
  2949. :scroll%=
  2950. :cell$=$
  2951. text(wi%,ic%)
  2952. :ok%=
  2953.  ok% 
  2954. buffer_length(wi%,ic%)
  2955. (S$)<=L% 
  2956. #    scratchpad$=$
  2957. text(wi%,ic%)
  2958.     $
  2959. text(wi%,ic%)=S$
  2960. redraw_icon(wi%,ic%)
  2961. set_caret(0,wi%,ic%)
  2962.  scroll% 
  2963. /      
  2964. scroller_press(wi%,ic%,Scroller%,13)
  2965.       ScrollChanged%=
  2966. >      
  2967.  Moves caret to next cell. New row if Shift pressed
  2968.         
  2969. $    
  2970. softerror(""""+S$+"""",7)
  2971. scroll_click
  2972.  (b% 
  2973.  %111)=2 
  2974. row%=(ic% 
  2975.     "0$tabcol%=
  2976. (row%):
  2977. redraw_icon(tabcreateW%,8)
  2978. list_click(x%,y%,b%,wi%)
  2979.  F%,N%,line%,xpos%,column%,last%
  2980. !block%=wi%
  2981.  "Wimp_GetWindowState",,block%
  2982.     ).line%=((block%!16-block%!24-y%+36) 
  2983.  36)-1
  2984.     *&xpos%=(x%-block%!4+block%!20) 
  2985.  xpos%<Lmargin% 
  2986.  xpos%>LenLine%-3 
  2987.  format$="horiz" 
  2988.     column%+=1
  2989.     /4  
  2990.  Tab%(column%)>xpos% 
  2991.  column%=PrintFields%+1
  2992.   column%-=1
  2993.     1%  F%=
  2994. fnum(
  2995. Form$,column%*2-1,2))
  2996.  (b% 
  2997.  %111) 
  2998.  chartype%(F%) 
  2999.     62    
  3000.  5,50,51,70,71,53,55,73,76:sortfield%=F% 
  3001. :sortfield%=0
  3002.     9:  $SortTextCol%="Sort "+Tag$(F%):sort_textcol%=column%
  3003.     :2  
  3004. lit(listM%,1,(format$="horiz") 
  3005.  nosort%)
  3006.     ;!  
  3007. show_menu(listM%,x%-64,y%)
  3008.  1,4:
  3009.   SHrecptr%=!recanchor%
  3010.   R%=SHrecptr%!(line%*4)
  3011.   last%=
  3012. (Form$) 
  3013.     @(  
  3014.  R%<RA% 
  3015.  R%>=0 
  3016. check_record 
  3017.     A$    addr=
  3018. find("#"+
  3019. (R%),key%,
  3020.  format$="vert" 
  3021.       
  3022.         N%+=1:line%-=1
  3023.     E.      
  3024.  SHrecptr%!(line%*4)<>R% 
  3025.  N%=last%
  3026.     F(      F%=
  3027. fnum(
  3028. Form$,N%*2-1,2))    
  3029.     G        
  3030.  F%>0 
  3031.  F%<=fields% 
  3032.     I$      
  3033.  vtype$(chartype%(F%)) 
  3034.     J,        
  3035.  "E":
  3036. restore_caret(field%(F%))
  3037.         
  3038.  "L":
  3039.     L#        S%=
  3040. scroller_number(F%)
  3041.     M*        
  3042. set_caret(0,scrollerW%(S%),0)
  3043.     N(        
  3044. restore_caret(starthere%)
  3045.       
  3046.     P        
  3047.  (b% 
  3048.  %111)=4 
  3049.       
  3050. open_window(mainW%)
  3051.       
  3052.       
  3053.  F%>0 
  3054.     UL        !block%=mainW%:block%!4=desc%(F%):
  3055.  "Wimp_GetIconState",,block%
  3056.     VJ        xmin%=block%!8:ymin%=block%!12:xmax%=block%!16:ymax%=block%!20
  3057.     W>        block%!4=field%(F%):
  3058.  "Wimp_GetIconState",,block%
  3059.     X>        w%=block%!16-block%!8+16:h%=block%!20-block%!12+16
  3060.     Y4        scrollx%=block%!8-8:scrolly%=block%!20+8
  3061.         
  3062.     [E          
  3063.  xmax%<block%!8:w%=block%!16-xmin%+16:scrollx%=xmin%-8
  3064.     \4          
  3065.  xmin%>block%!16:w%=xmax%-block%!8+16
  3066.     ]5          
  3067.  ymax%<block%!12:h%=block%!20-ymin%+16
  3068.     ^F          
  3069.  ymin%>block%!20:h%=ymax%-block%!12+16:scrolly%=ymax%+8
  3070.         
  3071.     `T        
  3072. position_window(mainW%,x%-(w% 
  3073.  2),y%-(h% 
  3074.  2),w%,h%,scrollx%,scrolly%)
  3075.       
  3076.     b        
  3077. match_click(wi%,ic%,b%)
  3078.  not%,and%,or%
  3079. b%=(b% 
  3080.  %111)
  3081. selected_esg(matchW%,1)=8 
  3082.     k#  
  3083. selected_esg(printW%,4) 
  3084.     l!    
  3085.  22:reportdest$="Window"
  3086.  23:reportdest$="File"
  3087.     n"    
  3088.  25:reportdest$="Printer"
  3089.  reportdest$="Window"
  3090.  ic% 
  3091.     u&    
  3092. selected(wi%,ic%),
  3093.     w+    
  3094. deselect(wi%,
  3095. selected_esg(wi%,1))
  3096.     x,    
  3097. select(wi%,8):$
  3098. text(wi%,0)="Print"
  3099.     y5    
  3100. close_it(wi%):
  3101. restore_caret(starthere%)    
  3102. (-1) 
  3103.     |@      Search$="":displayed%=REC%:leaf$=
  3104. key$(0),NameLength%)
  3105.       
  3106.     ~A      Search$=
  3107. query:displayed%=-1:leaf$=
  3108. query$,NameLength%)
  3109. D      $Query%="":
  3110. redraw_icon(queryW%,0):
  3111. set_caret(0,queryW%,0)
  3112.         
  3113. E    TextName$=$database%+".PrintJobs."+leaf$:$SaveName%=TextName$
  3114.  reportdest$ 
  3115.       
  3116.  "Window","Printer":
  3117. $      
  3118. do_it(Search$,displayed%)
  3119.       
  3120.  "File":
  3121.       savefunc$="Save list"
  3122. 3      $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  3123. 0      
  3124. shade(saveW%,4,
  3125. deselect(saveW%,4)
  3126. .      
  3127. position_window(saveW%,0,0,0,0,0,0)
  3128.        
  3129. set_caret(0,saveW%,2)
  3130.         
  3131. M    
  3132.  b%=4 
  3133. selected(wi%,8) 
  3134. close_it(wi%):
  3135. restore_caret(starthere%)
  3136.  b%=4 
  3137.       fieldfunc$="getcalc"
  3138. 9      fieldsM%=
  3139. field_menu(items%,2+(printorder$=""))
  3140. -      
  3141. show_pop_up_menu(fieldsM%,wi%,ic%)
  3142.         
  3143.  3,8,9,10:
  3144. !    
  3145. selected_esg(wi%,1) 
  3146.       
  3147.  3:S$="Count"
  3148.       
  3149.  8:S$="Print"
  3150.       
  3151.  9:S$="Mark"
  3152.       
  3153.  10:S$="Clear"
  3154.         
  3155. ,    $
  3156. text(wi%,0)=S$:
  3157. redraw_icon(wi%,0)
  3158. &    
  3159. shade(wi%,4,
  3160. selected(wi%,8))
  3161. &    
  3162. shade(wi%,6,
  3163. selected(wi%,8))
  3164. '    
  3165. shade(wi%,12,
  3166. selected(wi%,8))
  3167. 2    
  3168. position_window(printW%,0,0,0,0,0,0)
  3169. 6    
  3170. update_selection(
  3171. selected(wi%,ic%),"00")
  3172. 6    
  3173. update_selection(
  3174. selected(wi%,ic%),"KK")
  3175. 7    
  3176. update_selection(
  3177. selected(wi%,ic%),"SF")
  3178.  ic%=7 
  3179.     fieldfunc$="getcalc"
  3180. 7    fieldsM%=
  3181. field_menu(items%,2+(printorder$=""))
  3182. +    
  3183. show_pop_up_menu(fieldsM%,wi%,ic%)
  3184. mark_click(wi%,ic%,b%)
  3185. b%=(b% 
  3186.  %111)
  3187.  1,4:
  3188.  ic% 
  3189. selected(wi%,0) 
  3190. *      SHmarkptr%?REC%=1:MarkedRecs%+=1
  3191. ,      
  3192.  SHmarkptr%?REC%=0:MarkedRecs%-=1
  3193.         
  3194. clear_marks(RA%)
  3195. 6    
  3196.  b%=4 
  3197. show_pop_up_menu(markM%,wi%,ic%)
  3198.  ic%=2 
  3199. show_pop_up_menu(markM%,wi%,ic%)
  3200. warn_of_marks
  3201. warn_of_marks
  3202.  MarkedRecs%>0 
  3203. shade(markW%,1,
  3204. ticked(markM%,0) 
  3205. set_icon_cols(queryW%,5,7+16*10)
  3206. ticked(markM%,1) 
  3207. set_icon_cols(queryW%,5,7+16*11)
  3208. set_icon_cols(queryW%,5,7+16)
  3209. shade(markW%,1,
  3210. help_click(wi%,ic%,b%)
  3211.  new$,I%,L%,tag$,item$
  3212. butt%=(b% 
  3213.  %111)
  3214. z%=(butt%=1)-(butt%=4)
  3215.  butt% 
  3216.  2,4:
  3217.  ic%=19 
  3218. %    tag$=$
  3219. text(wi%,0):L%=
  3220. (tag$)
  3221. &    fieldsM%=
  3222. field_menu(items%,1)
  3223.         
  3224. (      item$=$
  3225. menu_text(fieldsM%,I%)
  3226.       I%+=1
  3227. %    
  3228. item$,L%)=tag$ 
  3229.  I%>items%
  3230. )    
  3231. tick_one(fieldsM%,0,items%,I%-1)
  3232. +    
  3233. show_pop_up_menu(fieldsM%,wi%,ic%)
  3234.  butt% 
  3235.  1,4:
  3236.  ic% 
  3237.  1:new$="NOT (":not%=
  3238.  9:new$=" AND "
  3239.  10:new$=" OR "
  3240.  16,17:
  3241. S    Match_tag%=
  3242. find_next_valid_field(Match_tag%,"help",z%*((ic%=16)-(ic%=17)))
  3243. J    
  3244.  Match_tag%>0 
  3245. text(wi%,0)=Tag$(Match_tag%) 
  3246. text(wi%,0)=""
  3247. redraw_icon(wi%,0)
  3248. C    
  3249.  21:$Query%="":
  3250. redraw_icon(queryW%,0):
  3251. set_caret(0,wi%,6)
  3252.      op%=
  3253. selected_esg(wi%,1)
  3254.  op% 
  3255.       
  3256.  2:op$="="
  3257.       
  3258.  3:op$="{"
  3259.       
  3260.  4:op$="<"
  3261.       
  3262.  5:op$=">"
  3263.       
  3264.  11:op$="<>"
  3265.       
  3266.  13:op$=">="
  3267.       
  3268.  14:op$="<="
  3269.       
  3270.  15:op$="}{"
  3271.       
  3272.  22:op$="{{"
  3273.         
  3274.     tag$=$
  3275. text(wi%,0)
  3276.     contents$=$
  3277. text(wi%,6)
  3278.     new$=tag$+op$+contents$
  3279. 6    
  3280. close_it(helpW%):
  3281. set_caret(0,queryW%,0)
  3282.  new$<>"" 
  3283.  "Wimp_GetCaretPosition",,block%
  3284.   handle%=!block%
  3285.  handle%=queryW% 
  3286. enter_tag(new$)
  3287. /    
  3288.  $Query%+=new$:
  3289. redraw_icon(queryW%,0)
  3290.  not%=
  3291. $Query%)<>")" 
  3292.  $Query%+=")":not%=
  3293. redraw_icon(queryW%,0)
  3294. iconbar_click
  3295.  %111 
  3296. position_window(prefsW%,0,0,0,0,0,0)
  3297. selected(passW%,12) 
  3298. close_window(saveW%)
  3299.     )    
  3300. show_menu(iconbarM%,x%-64,ybar%)
  3301.  $dbase%="No data" 
  3302.     $SaveName%="!DataBase"
  3303. 1    $SaveSprite%="snew_appl;Pptr_hand,4,0;R2"
  3304.      savefunc$="New database"
  3305. B    $
  3306. text(saveW%,4)="":
  3307. shade(saveW%,4,
  3308. deselect(saveW%,4)
  3309. .    
  3310.  "Wimp_CreateMenu",,saveW%,x%-50,440
  3311. show_windows
  3312. update_external(REC%)
  3313.  chartype%(OLE%) 
  3314. show_text_block(OLE%,REC%)
  3315. show_picture(OLE%,REC%)
  3316. redraw_icon(mainW%,field%(OLE%))
  3317. restore_caret(returnto%)
  3318. restore_caret(ic%)
  3319.  Access% 
  3320.  ic%=-1 
  3321.  ic%=starthere%
  3322.  ic%>=0 
  3323. $     
  3324. set_caret(0,mainW%,ic%)
  3325. identify_field(ic%)
  3326. main_click(wi%,ic%,b%)
  3327.  P%,F%,H$,L%,T%,N$,field$,V%,char%
  3328.  exit% 
  3329.  present%=7 
  3330.  adjust%=
  3331. validate(Fieldnumber%,T%,N$)=
  3332.  changed%=
  3333. update_calcs(Fieldnumber%)
  3334.  flash% 
  3335. set_icon(wi%,field%(flash%),state%):flash%=
  3336.  present% 
  3337.  0,3:
  3338. design_field(b%,ic%,
  3339. first_writable>0 
  3340. default_key
  3341. design_field(b%,ic%,
  3342.  5,7:
  3343.  adjust% 
  3344. design_field(b%,ic%,
  3345. 7        
  3346. identify_field(ic%)
  3347. 9d    
  3348.  b%<>2 
  3349.  (Fieldnumber%=0 
  3350.  Fieldnumber%>fields%) 
  3351.  char%=-1 
  3352.  char%=chartype%(Fieldnumber%)
  3353. :,    
  3354. selected(prefsW%,19) 
  3355. relations
  3356.  2047 
  3357.       
  3358.       
  3359.  char% 
  3360. >D        
  3361. show_user_menu(menubuff%,Fieldnumber%,(b% 
  3362.  %111))
  3363. ?g        
  3364.  9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31:
  3365. fkey_status(char%-9)
  3366.         
  3367. A!        
  3368. close_window(saveW%)
  3369. B.        
  3370. selected(passW%,11) 
  3371.  Modify% 
  3372. C           
  3373. set_up_field_menu
  3374. D)          
  3375. show_menu(mainM%,x%-64,y%)
  3376.         
  3377.       
  3378.       
  3379.       
  3380.  char% 
  3381. ID        
  3382.  customise% 
  3383. (libfunc$+"_button(wi%,ic%,b%)")
  3384. Jq        
  3385.  0,1,2,3,4,5,6,7,8,39,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:
  3386. K.        
  3387.  "Wimp_GetCaretPosition",,block%
  3388.         first%=
  3389. find_caret
  3390. M0        
  3391. select_range(first%,Fieldnumber%,
  3392. Nk        
  3393.  9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30:
  3394. keypad_click(wi%,char%-9,1)
  3395. Om        
  3396. check_record 
  3397. invert(wi%,ic%):
  3398. filter(wi%,b%,
  3399. selected(wi%,field%(buttonfield%(0,22))))
  3400.         
  3401.         
  3402. RK          
  3403. (-2):displayit%?Fieldnumber%=(displayit%?Fieldnumber%) 
  3404.           
  3405. T*          col%=
  3406. get_icon_cols(wi%,ic%)
  3407. U6          col%=((col%>>4) 
  3408.  (col%<<4)) 
  3409.  %11111111
  3410. V*          
  3411. set_icon_cols(wi%,ic%,col%)
  3412. W'          boxon%=((col% 
  3413.  %1111)<2)
  3414. X*          
  3415. update_selection(boxon%,"")
  3416.         
  3417. ZY        
  3418.  37,38:
  3419. (-2):displayit%?Fieldnumber%=(displayit%?Fieldnumber%) 
  3420.  1        
  3421.         
  3422.  41,42,43,61,62:
  3423. \(        col%=
  3424. get_icon_cols(wi%,ic%)
  3425. ]4        col%=((col%>>4) 
  3426.  (col%<<4)) 
  3427.  %11111111
  3428. ^(        
  3429. set_icon_cols(wi%,ic%,col%)
  3430. _%        boxon%=((col% 
  3431.  %1111)<2)
  3432. `(        
  3433. update_selection(boxon%,"")
  3434. aD        
  3435. show_user_menu(menubuff%,Fieldnumber%,(b% 
  3436.  %111))
  3437.         
  3438. cc        
  3439.  link$(Fieldnumber%)="" 
  3440. softerror("",188) 
  3441. softerror(
  3442. link$(Fieldnumber%),2),186)
  3443.         
  3444. ec        
  3445.  link$(Fieldnumber%)="" 
  3446. softerror("",188) 
  3447. softerror(
  3448. link$(Fieldnumber%),2),187)
  3449.         
  3450.         
  3451.           
  3452. (-1):
  3453. i_          
  3454.  $Rf%(Fieldnumber%)="" 
  3455. softerror("",188) 
  3456. softerror($Rf%(Fieldnumber%),165)
  3457. jK          
  3458. (-2):displayit%?Fieldnumber%=(displayit%?Fieldnumber%) 
  3459.           
  3460. l*          col%=
  3461. get_icon_cols(wi%,ic%)
  3462. m6          col%=((col%>>4) 
  3463.  (col%<<4)) 
  3464.  %11111111
  3465. n*          
  3466. set_icon_cols(wi%,ic%,col%)
  3467. o'          boxon%=((col% 
  3468.  %1111)<2)
  3469. p4          
  3470. update_selection(boxon%,"")          
  3471.         
  3472.       
  3473.       
  3474.       
  3475.  char% 
  3476. uD        
  3477.  customise% 
  3478. (libfunc$+"_button(wi%,ic%,b%)")
  3479. v.        
  3480. internet($Rf%(Fieldnumber%))
  3481. wk        
  3482.  9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30:
  3483. keypad_click(wi%,char%-9,4)
  3484. xm        
  3485. check_record 
  3486. invert(wi%,ic%):
  3487. filter(wi%,b%,
  3488. selected(wi%,field%(buttonfield%(0,22))))
  3489. y?        
  3490. selected(passW%,14) 
  3491. match(x%-396,y%-131)
  3492. zD        
  3493. show_user_menu(menubuff%,Fieldnumber%,(b% 
  3494.  %111))
  3495. {(        
  3496. check_record 
  3497.         
  3498.         
  3499. ~4          
  3500. (-2):
  3501. enter_tag(Tag$(Fieldnumber%))
  3502. .          
  3503. edit_blob(Fieldnumber%,char%)
  3504.         
  3505. 8        
  3506.  37,38,39,40:
  3507. edit_blob(Fieldnumber%,char%)
  3508.         
  3509.  41,42,43:
  3510.         
  3511. 4          
  3512. (-2):
  3513. enter_tag(Tag$(Fieldnumber%))
  3514.           
  3515.  Access%:
  3516.           
  3517. invert(wi%,ic%)
  3518. S          
  3519. selected(wi%,ic%) 
  3520.  $Rf%(Fieldnumber%)=" " 
  3521.  $Rf%(Fieldnumber%)=""
  3522.         
  3523.         
  3524.  61,62:
  3525.         
  3526. 4          
  3527. (-2):
  3528. enter_tag(Tag$(Fieldnumber%))
  3529.           
  3530.  Access%:
  3531. 5          V%=
  3532. val(wi%,ic%):P%=
  3533. $V%,";S"):V%+=P%+1
  3534.           
  3535.  $V% 
  3536. D            
  3537.  "null","dontcare":$V%="yes":$Rf%(Fieldnumber%)=" "
  3538. 8            
  3539.  "yes":$V%="no":$Rf%(Fieldnumber%)=
  3540.             
  3541.  "no":
  3542. 8            
  3543.  char%=61 
  3544.  $V%="null" 
  3545.  $V%="dontcare"
  3546. %            $Rf%(Fieldnumber%)=""
  3547.           
  3548. #          
  3549. redraw_icon(wi%,ic%)
  3550.         
  3551.                  
  3552. :        
  3553.  Access% 
  3554.  quit%=
  3555. check_record 
  3556.  quit%=
  3557. ,        
  3558. execute_file(Fieldnumber%)
  3559.         
  3560. +        
  3561. link$(Fieldnumber%),1)="@" 
  3562. *          dir$=
  3563. link$(Fieldnumber%),2)
  3564. 0          dir$=
  3565. filename(dir$,"PrintRes",-1)
  3566. V          
  3567.  "OS_CLI","Filer_OpenDir "+dir$+" "+
  3568. (oldx%)+" "+
  3569. (oldy%)+" "+dirdisp$
  3570. !          
  3571. softerror("",91)
  3572.         
  3573.         
  3574.         
  3575.         
  3576. 4          
  3577. (-2):
  3578. enter_tag(Tag$(Fieldnumber%))
  3579. .          
  3580. get_remote_file(Fieldnumber%)
  3581.         
  3582.            
  3583.         
  3584.         
  3585. (-1) 
  3586. #          
  3587. lookup(Fieldnumber%)
  3588. 3          
  3589. relations:
  3590. tone_dial(Fieldnumber%)
  3591.         
  3592.       
  3593.       
  3594.       
  3595.  char% 
  3596. w        
  3597.  0,1,2,3,4,5,6,7,8,39,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:      
  3598. \        
  3599.  Access% 
  3600.  hide%?Fieldnumber%=0 
  3601.  dragfield%=Fieldnumber%:
  3602. init_drag(wi%,ic%,5)
  3603.       
  3604.      
  3605.       
  3606.  256:
  3607.       
  3608.  char% 
  3609. q        
  3610.  0,1,2,3,4,5,6,7,8,39,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:
  3611. n        
  3612. get_icon_cols(wi%,ic%)<>winback%*17 
  3613. invert(wi%,ic%):
  3614. update_selection(
  3615. selected(wi%,ic%),"")
  3616.       
  3617.       
  3618.  vtype$(char%)="E" 
  3619. D        
  3620. find_caret=0 
  3621. get_icon_cols(wi%,ic%)<>winback%*17 
  3622. :          !block%=wi%:
  3623.  "Wimp_GetWindowState",,block%
  3624. [          
  3625.  Access% 
  3626.  "Wimp_SetCaretPosition",wi%,ic%,x%-block%!4+block%!20,y%,-1,-1
  3627.         
  3628.       
  3629.      
  3630.       
  3631.  1024:
  3632.       
  3633. (-2) 
  3634.         
  3635.  char% 
  3636. s          
  3637.  0,1,2,3,4,5,6,7,8,39,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:
  3638. ,          
  3639. enter_tag(Tag$(Fieldnumber%))
  3640.         
  3641.         
  3642. !        
  3643.  vtype$(char%)="E" 
  3644. 6          
  3645. get_icon_cols(wi%,ic%)<>winback%*17 
  3646. <            !block%=wi%:
  3647.  "Wimp_GetWindowState",,block%
  3648. ]            
  3649.  Access% 
  3650.  "Wimp_SetCaretPosition",wi%,ic%,x%-block%!4+block%!20,y%,-1,-1
  3651.           
  3652. &          
  3653. user_menu(Fieldnumber%)
  3654.         
  3655.       
  3656.         
  3657. user_menu(F%)
  3658.  I%,M%
  3659. selected(prefsW%,49) 
  3660.   I%+=1
  3661.  chartype%(I%)=33 
  3662.  Tag$(I%)=Tag$(F%) 
  3663.  M%=I%
  3664.  M%>0 
  3665.  I%=fields%
  3666.  M%>0 
  3667. show_user_menu(menubuff%,M%,4) 
  3668.  "Wimp_CreateMenu",,-1
  3669. selected(prefsW%,19) 
  3670. relations
  3671. find_caret
  3672.  wi%,ic%,S%,F%
  3673.  "Wimp_GetCaretPosition",,block%
  3674. wi%=!block%:ic%=block%!4
  3675. scroller_num2(wi%)
  3676.  wi% 
  3677.  mainW%:F%=((block%!4)+2) 
  3678.  scrollerW%(S%):F%=scrolldata%(S%,0)
  3679. tone_dial(F%)
  3680. -f$="<Pbase$Dir>.Resources.Dial "+$Rf%(F%)
  3681.  "OS_File",5,f$ 
  3682.  d%=0 
  3683. phone(F%) 
  3684. >DialDelay%
  3685.  $Rf%(F%)<>"" 
  3686.  "OS_CLI","Run "+f$
  3687. phone(F%)
  3688.  D$,T$
  3689. text(mainW%,desc%(F%)))
  3690. u(Tag$(F%))
  3691. D$,"TEL")>0 
  3692. T$,"TEL")>0) 
  3693. enter_tag(tag$)
  3694.  wi%,S$
  3695.  "Wimp_GetCaretPosition",,block%
  3696. +wi%=!block%:ic%=block%!4:pos%=block%!20
  3697.  wi% 
  3698.  queryW%,helpW%,calcW%,extracalcW%:
  3699.   S$=$
  3700. text(wi%,ic%)
  3701. #  S$=
  3702. S$,pos%)+tag$+
  3703. S$,pos%+1)
  3704. text(wi%,ic%)=S$
  3705. set_caret(pos%+
  3706. (tag$),wi%,ic%)
  3707. redraw_icon(wi%,ic%)
  3708. set_up_field_menu
  3709.  I%,tabmen%,V%
  3710. tabmen%=(LastTable%<>-1)
  3711.  tabmen% 
  3712. make_table_menu(TabsLoaded$):
  3713. tick_one(valtablesM%,0,LastTable%,LastTable%+1)
  3714. V%=chartype%(Fieldnumber%)
  3715.  I%=0 
  3716. lit(fieldM%,I%,
  3717. $AnalyseFunc%="Analyse"
  3718.  Fieldnumber%>0 
  3719. get_icon_cols(wi%,ic%)<>winback%*17 
  3720.   Menufield%=Fieldnumber%
  3721. lit(mainM%,1,
  3722. E  $Fieldpos%="Field: "+Tag$(Fieldnumber%):Menufield%=Fieldnumber%
  3723. &  $LinkTitle%="Field: "+Fieldname$
  3724. >  $CalcForm%=Tag$(Fieldnumber%)+"=":
  3725. redraw_icon(calcW%,0)
  3726.  5,50,51,70,71:
  3727. $    isadate%=
  3728. lit(fieldM%,1,
  3729. &    $AnalyseFunc%="Analyse months"
  3730. :isadate%=
  3731. is_a_key(Fieldnumber%)>=0 
  3732. lit(fieldM%,1,
  3733. _    
  3734.  isadate%=
  3735. selected(mainW%,field%(Fieldnumber%)) 
  3736.  $AnalyseFunc%="Analyse index"
  3737.  0,1,2,3,4,5,8,63:
  3738. lit(fieldM%,0,Access%)
  3739. lit(fieldM%,2,Access%)
  3740. !)    
  3741. lit(fieldM%,3,Access% 
  3742.  tabmen%)
  3743. lit(fieldM%,5,Access%)
  3744. lit(fieldM%,9,
  3745. set_up_key_window
  3746. %*    $ChangeTitle%="Field: "+Fieldname$
  3747. &3    $
  3748. text(changeW%,0)="":$
  3749. text(changeW%,1)=""
  3750. link_status
  3751.  6,7:
  3752. lit(fieldM%,0,Modify%)
  3753. lit(fieldM%,4,Modify%)
  3754. +T    
  3755.  V%=6 
  3756. calc_link("Calculations...",6) 
  3757. calc_link("Combine fields...",7)
  3758. set_up_key_window    
  3759. -H    
  3760.  41,42,43,61,62:
  3761. lit(fieldM%,2,Modify%):
  3762. lit(fieldM%,9,Modify%)
  3763. .4    
  3764.  46,47,48,49,50,51,52,53,54,55,56,57,58,79:
  3765.  V%=47 
  3766. 0!      
  3767. lit(fieldM%,4,Modify%)
  3768. 1"      
  3769. lit(fieldM%,10,Modify%)
  3770. 2,      
  3771. calc_link("Set base value...",47)
  3772. 3        
  3773. lit(fieldM%,0,Access%)
  3774. set_up_key_window
  3775.  36,39:
  3776. 7D    
  3777. blob_path(
  3778. ,$database%,REC%,Fieldnumber%,V%,object$)>=0 
  3779. 8'      $RemoveOb%="Remove text file"
  3780. 9#      $SaveOb%="Save text file"
  3781. :!      
  3782. lit(fieldM%,6,Access%)
  3783. ;.      
  3784. lit(fieldM%,7,
  3785. selected(passW%,13))
  3786. <5      $SaveName%=$database%+".PrintJobs.TextFile"
  3787. =3      $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  3788.       savefunc$="Save text"
  3789. ?        
  3790.  37,40:
  3791. AD    
  3792. blob_path(
  3793. ,$database%,REC%,Fieldnumber%,V%,object$)>=0 
  3794. B$      $RemoveOb%="Remove sprite"
  3795. C       $SaveOb%="Save sprite"
  3796. D!      
  3797. lit(fieldM%,6,Access%)
  3798. E.      
  3799. lit(fieldM%,7,
  3800. selected(passW%,13))
  3801. F3      $SaveName%=$database%+".PrintJobs.Sprite"
  3802. G3      $SaveSprite%="sfile_ff9;Pptr_hand,4,0;R2"
  3803. H!      savefunc$="Save sprite"
  3804. I        
  3805. KD    
  3806. blob_path(
  3807. ,$database%,REC%,Fieldnumber%,V%,object$)>=0 
  3808. L&      $RemoveOb%="Remove drawfile"
  3809. M"      $SaveOb%="Save drawfile"
  3810. N!      
  3811. lit(fieldM%,6,Access%)
  3812. O.      
  3813. lit(fieldM%,7,
  3814. selected(passW%,13))
  3815. P5      $SaveName%=$database%+".PrintJobs.DrawFile"
  3816. Q3      $SaveSprite%="sfile_aff;Pptr_hand,4,0;R2"
  3817.       savefunc$="Save draw"
  3818. S        
  3819. T"    
  3820.  35:                     
  3821. U%    $RemoveOb%="Unlink directory"
  3822.     $SaveOb%="Save object"
  3823. W;    
  3824.  link$(Fieldnumber%)<>"" 
  3825. lit(fieldM%,6,Access%)
  3826. Y     $RemoveOb%="Unlink file"
  3827.     $SaveOb%="Save object"
  3828. [;    
  3829.  link$(Fieldnumber%)<>"" 
  3830. lit(fieldM%,6,Access%)
  3831. ]     $RemoveOb%="Unlink file"
  3832.     $SaveOb%="Save object"
  3833. _"    
  3834.  $Rf%(Fieldnumber%)<>"" 
  3835. `9      
  3836. lit(fieldM%,6,Access%):
  3837. lit(fieldM%,7,Access%)
  3838. a.      $SaveName%=
  3839. leaf($Rf%(Fieldnumber%))
  3840. bK      S$=$
  3841. val(mainW%,field%(Fieldnumber%)):P%=
  3842. S$,";S"):spr$=
  3843. S$,P%+1)
  3844. c/      $SaveSprite%=spr$+";Pptr_hand,4,0;R2"
  3845.       savefunc$=$SaveOb%
  3846. e        
  3847. lit(fieldM%,0,Access%)
  3848. lit(fieldM%,2,Access%)
  3849. set_up_key_window
  3850. i*    $ChangeTitle%="Field: "+Fieldname$
  3851. j3    $
  3852. text(changeW%,0)="":$
  3853. text(changeW%,1)=""
  3854.  64,65,66,67:
  3855. l"    $Fieldpos%+="#"+
  3856. (Scrcol%)
  3857. m)    
  3858. lit(fieldM%,3,Access% 
  3859.  tabmen%)
  3860. link_status
  3861.     $RemoveOb%="Blank list"
  3862.     $SaveOb%="Save as list"
  3863. lit(fieldM%,8,Access%)
  3864. rD    
  3865. blob_path(
  3866. ,$database%,REC%,Fieldnumber%,V%,object$)>=0 
  3867. s!      
  3868. lit(fieldM%,6,Access%)
  3869. t.      
  3870. lit(fieldM%,7,
  3871. selected(passW%,13))
  3872. u<      $SaveName%=$database%+".PrintJobs."+
  3873. leaf(object$)
  3874. v        
  3875. x@  $
  3876. text(saveW%,4)="":
  3877. shade(saveW%,4,
  3878. deselect(saveW%,4)
  3879. lit(mainM%,1,
  3880. ):$Fieldpos%="Field: """""
  3881. set_up_key_window
  3882.  I%,J%
  3883.  I%=0 
  3884.   keyfield%(I%)=0
  3885.  J%=12 
  3886.      $
  3887. text(keyW%,4*I%+J%)=""
  3888. keyfield%(0)=Fieldnumber%
  3889. text(keyW%,12)=Tag$(Fieldnumber%)
  3890. text(keyW%,14)="L"
  3891. text(keyW%,15)=
  3892. (len%(Fieldnumber%))
  3893. -keylimit%=TextLength%:$
  3894. text(keyW%,29)=""
  3895. keylen%=keylimit%
  3896. update_selection(add%,field$)
  3897.  P%,SP%,F%,SF%
  3898. "F%=Fieldnumber%:SF%=(F% 
  3899.  128)
  3900.  field$="" 
  3901. /  field$=
  3902. ~(F%):
  3903.  F%<16 
  3904.  field$="0"+field$
  3905. 4  sfield$=
  3906. ~(SF%):
  3907.  SF%<16 
  3908.  sfield$="0"+sfield$
  3909.  add% 
  3910. (-1) 
  3911.  chartype%(F%) 
  3912. %      
  3913.  36,39:printorder$+=field$
  3914.        
  3915. :printorder$+=sfield$
  3916.         
  3917.  printorder$+=field$
  3918. enable_row(calcrow%?Fieldnumber%,
  3919. lit(printM%,7,
  3920. lit(printM%,8,
  3921. lit(mainM%,7,
  3922. selected(passW%,13))
  3923. $    P%=
  3924. printorder$,field$,P%+1)
  3925.  ((P%-1) 
  3926.  2)=0 
  3927.  P%=0
  3928.  P%>0 
  3929. 9    printorder$=
  3930. printorder$,P%-1)+
  3931. printorder$,P%+2)
  3932. ,    
  3933. enable_row(calcrow%?Fieldnumber%,
  3934.         
  3935.         
  3936. )      SP%=
  3937. printorder$,sfield$,SP%+1)
  3938. !    
  3939.  ((SP%-1) 
  3940.  2)=0 
  3941.  SP%=0
  3942.  SP%>0 
  3943. =      printorder$=
  3944. printorder$,SP%-1)+
  3945. printorder$,SP%+2)
  3946. .      
  3947. enable_row(calcrow%?Fieldnumber%,
  3948.         
  3949.  printorder$="" 
  3950. lit(printM%,7,
  3951. lit(printM%,8,
  3952. lit(mainM%,7,
  3953. shade(matchW%,7,printorder$<>"")
  3954. lit(printM%,9,printorder$<>"")
  3955. print_click(wi%,wi2%,ic%,b%)
  3956.  d$,fg%,bg%,colour%,z%
  3957. b%=(b% 
  3958.  %111)
  3959. selected(wi%,26) 
  3960. show_menu(wi2%,x%-500,y%+200)
  3961.  1,4:
  3962.  b%=4 
  3963.  z%=1 
  3964.  z%=-1
  3965.  ic% 
  3966. 5    
  3967.  15,16:
  3968. deselect(wi2%,
  3969. selected_esg(wi2%,2))
  3970. #    
  3971.  22,23,25:
  3972. set_dest_sprite
  3973. '    
  3974.  ic%<>25 
  3975. close_window(wi2%)
  3976. -    
  3977. deselect(wi2%,
  3978. selected_esg(wi2%,2))
  3979. 3    
  3980. selected_esg(wi%,3)=-1 
  3981. select(wi%,15)
  3982.  40,41:
  3983. (    
  3984. shade(wi%,43,
  3985. selected(wi%,40))
  3986. (    
  3987. shade(wi%,51,
  3988. selected(wi%,40))
  3989.     $
  3990. text(wi2%,0)=pdriver$
  3991. *    
  3992. position_window(wi2%,0,0,0,0,0,0)
  3993. /    
  3994. (-1) 
  3995.  d$="Initial" 
  3996.  d$="Resources"
  3997. K    
  3998. get_options(wi%,wi2%,"<Pbase$Dir>."+d$+".!PrintOpts"):
  3999. redraw(wi%)
  4000. P    
  4001.  b%=4 
  4002. close_window(wi%):
  4003. restore_caret(returnto%) 
  4004. match(0,0)
  4005. 4    
  4006. restore_window(wi%,remember%+winbuff%(3,1))
  4007. L    
  4008.  b%=4 
  4009. close_window(wi%):
  4010. restore_caret(returnto%) 
  4011. redraw(wi%)
  4012. selected(wi%,31) 
  4013. D      
  4014. save_options(wi%,wi2%,"<Pbase$Dir>.Resources.!PrintOpts")
  4015.       
  4016. C      
  4017.  prtopts$="" 
  4018.  prtopts$=$database%+".PrintRes.PrintOpts"
  4019.       $SaveName%=prtopts$
  4020. 3      $SaveSprite%="sfile_7f5;Pptr_hand,4,0;R2"
  4021. ,      $
  4022. text(saveW%,4)="Default options"
  4023. 6      
  4024. shade(saveW%,4,
  4025. deselect(saveW%,4)      
  4026. "      savefunc$="Save options"
  4027. %      
  4028. show_menu(saveW%,x%-64,y%)
  4029.         
  4030.  53,54,55:
  4031. I    colour%=
  4032. get_icon_cols(wi%,ic%):fg%=colour% 
  4033.  16:bg%=colour% 
  4034.     fg%=(fg%+z%+16) 
  4035. >    colour%=fg%+bg%*16:
  4036. set_icon_cols(wi%,ic%,colour%)    
  4037. enable_print_setup(wi%,wi2%)
  4038. set_dest_sprite
  4039.  Z$,sprite$,wi%
  4040. wi%=printW%
  4041. selected_esg(wi%,4) 
  4042.  22:sprite$="Swin2"
  4043.  23:sprite$="Ssmall_fff"
  4044.  25:sprite$="Sprinter"
  4045. val(matchW%,11)=sprite$+";R2"
  4046. redraw_icon(matchW%,11)
  4047. shade(wi%,42,
  4048. selected(wi%,25))
  4049. selected(wi%,25) 
  4050. shade(matchW%,11,
  4051. printer_driver(Z$))
  4052. shade(matchW%,11,
  4053. printer_driver(
  4054.  driver$)
  4055.  xres%,yres%
  4056. :driver$=
  4057. msg("Err180"):=
  4058.  "PDriver_Info" 
  4059.  ,xres%,yres%,,driver$
  4060. (driver$+=" "+
  4061. (xres%)+" x "+
  4062. (yres%)
  4063. printer_click(wi%,wi2%,ic%,b%)
  4064.  copies%,z%
  4065. b%=(b% 
  4066.  %111)
  4067.  1,4:
  4068.  b%=4 
  4069.  z%=1 
  4070.  z%=-1
  4071.  ic% 
  4072. !    
  4073.  38,48,77:
  4074. convert_units
  4075. 1    
  4076.  7,8:
  4077. deselect(wi%,
  4078. selected_esg(wi%,3))
  4079. H    
  4080.  ic%=8 
  4081. deselect(wi2%,
  4082. selected_esg(wi2%,9)):
  4083. select(wi2%,80)
  4084. g    
  4085. restore_window(wi2%,remember%+winbuff%(2,1)):
  4086.  b%=4 
  4087. close_window(wi2%) 
  4088. redraw(wi2%)
  4089. )    
  4090.  b%=4 
  4091. close_window(wi2%)
  4092.  44,47:
  4093. "    copies%=
  4094. text(wi2%,45))
  4095. ,    
  4096.  ic%=47 
  4097.  copies%+=z% 
  4098.  copies%-=z%
  4099. -    
  4100.  copies%=0 
  4101.  copies%=100 
  4102.  copies%=1
  4103. "    $
  4104. text(wi2%,45)=
  4105. (copies%)
  4106. redraw_icon(wi2%,45)
  4107.  59,72:
  4108. >    
  4109.  "Font_ListFonts",,0,(1<<19),,0 
  4110.  ,,,size%,,indsize%
  4111.  SHfontmenu%=0 
  4112. G      SHfontmenu%=
  4113. extend_named_sliding_block(fontanchor%,SHclaim%)
  4114. ?      
  4115.  SHfontmenu%=
  4116. claim_page(fontanchor%,size%+indsize%)
  4117.         
  4118.     fontM%=SHfontmenu%  
  4119. G    
  4120.  "Font_ListFonts",,fontM%,(1<<19),size%,fontM%+size%,indsize%
  4121. *    
  4122. show_pop_up_menu(fontM%,wi2%,ic%)
  4123. "    
  4124.  ic%=59 
  4125.  fontdisplay%=57
  4126. "    
  4127.  ic%=72 
  4128.  fontdisplay%=71
  4129.  B    
  4130.  61,62,63,64,84:
  4131. shade(wi2%,65,(
  4132. selected_esg(wi2%,7)<0))
  4133. enable_print_setup(wi%,wi2%)
  4134. enable_print_setup(wi%,wi2%)
  4135. live%()=42,-1:
  4136.  'Lots more'
  4137. enable(wi%,
  4138. selected(wi%,25)):
  4139.  Printer dest
  4140. selected_esg(wi%,3)=-1 
  4141. selected_esg(wi2%,2)=-1 
  4142. select(wi%,15)
  4143. selected(wi%,16) 
  4144. selected(wi2%,8) 
  4145. deselect(wi%,46)
  4146. +$live%()=46,-1:
  4147.  Enable 'Sort on'
  4148. enable(wi%,
  4149. selected(wi%,15) 
  4150. selected(wi2%,7)):
  4151.  Horiz or Table
  4152. --live%()=44,47,-1:
  4153.  Sort field & direction
  4154. enable(wi%,
  4155. selected(wi%,46)):
  4156.  Sort on switch set
  4157. /9live%()=43,51,-1:
  4158.  Shrink row switch & Row terminator
  4159. enable(wi%,
  4160. selected(wi%,40)):
  4161.  Single row format set
  4162. 1+live%()=65,-1:
  4163.  User-defined point-size
  4164. enable(wi2%,
  4165. selected_esg(wi2%,7)=-1):
  4166.  No fixed size selected
  4167. 3&live%()=68,-1:
  4168.  Margins as printer
  4169. enable(wi2%,
  4170. printer_driver(pdriver$))
  4171. 5$live%()=14,15,16,18,-1:
  4172.  Margins
  4173. enable(wi2%,
  4174. selected(wi2%,68))
  4175. 7>live%()=23,24,69,-1:
  4176.  Enable extra cols, width, extra rows
  4177. enable(wi2%,
  4178. selected(wi2%,7)):
  4179.  Table
  4180. 92live%()=80,81,85,86,-1:
  4181.  Disable print-columns
  4182. enable(wi2%,
  4183. selected(wi2%,8)):
  4184.  Label
  4185. live%()=82,-1:
  4186.  Gutter
  4187. enable(wi2%,
  4188. selected_esg(wi2%,9)>80):
  4189.  2,3 or 4 cols selected
  4190. =2live%()=28,29,30,31,32,34,39,41,51,52,53,55,-1
  4191. enable(wi2%,
  4192. selected(wi2%,8)):
  4193.  Enable special label settings
  4194. ?3live%()=40,78,-1:
  4195.  Enable substitution on label
  4196. selected(wi2%,8) 
  4197. deselect(wi2%,39)
  4198. enable(wi2%,
  4199. selected(wi2%,8) 
  4200. selected(wi2%,39)):
  4201.  Subst.switch set
  4202. keypad_click(wi%,ic%,b%)
  4203.  handle%,icon%,T%,flag%,N$,date$,retry%
  4204. validate(Fieldnumber%,T%,N$)=
  4205. G(changed%=
  4206. update_calcs(Fieldnumber%)
  4207.  ic%<>1 
  4208.  HasTitle%=1 
  4209. close_window(titleW%):HasTitle%=2 
  4210.  ic% 
  4211.  18,20,21:flag%=
  4212.  Allow table listing & scratchpad operations
  4213. :flag%=
  4214. check_record
  4215.  retry% 
  4216.  flag% 
  4217. deselect(wi%,22):Filter$="TRUE":
  4218. close_window(relateW%)
  4219.  flash% 
  4220. set_icon(mainW%,field%(flash%),state%):flash%=
  4221. b%=(b% 
  4222.  %111)
  4223. fkey_status(ic%)
  4224.  1,4:
  4225.  b%=4 
  4226.  z%=1 
  4227.  z%=-1
  4228.  ic% 
  4229. W6    
  4230.  merging% 
  4231. scan(z%,
  4232. text(wi%,23)))
  4233.  b%=1 
  4234. Z:      
  4235.  HasTitle%=2 
  4236.  HasTitle%=1:
  4237. open_window(mainW%)
  4238.       
  4239.  stop%=
  4240. \        
  4241. ]%    
  4242.  2:addr=
  4243. moveto(key%,top,z%)
  4244. ^&    
  4245.  3:addr=
  4246. moveto(key%,top,-z%)
  4247. _&    
  4248.  4:addr=
  4249. moveto(key%,addr,z%)
  4250. `'    
  4251.  5:addr=
  4252. moveto(key%,addr,-z%)
  4253. a(    
  4254.  6:addr=
  4255. fast_wind(top,addr,z%)
  4256. b)    
  4257.  7:addr=
  4258. fast_wind(top,addr,-z%)
  4259. key_select(z%)
  4260. key_select(-z%)
  4261. subfile(z%)
  4262. subfile(-z%)
  4263. g-    
  4264. rotate:addr=
  4265. moveto(key%,top,1)
  4266. h"    
  4267. allow_search(wi%,z%)
  4268. i<    
  4269.  b%=4 
  4270. display(key%,-1) 
  4271. display(key%,-2) 
  4272. j#    
  4273.  15:addr=
  4274. shift(z%,key%,0)
  4275. (-1) 
  4276. l!      filemem%(file%,key%)=-1
  4277. m(      addr=
  4278. find("#"+
  4279. (REC%),key%,
  4280.       
  4281. display(key%,addr)
  4282. o        
  4283. p$    
  4284.  16:addr=
  4285. shift(-z%,key%,0)
  4286. (-1) 
  4287. r!      filemem%(file%,key%)=-1
  4288. s(      addr=
  4289. find("#"+
  4290. (REC%),key%,
  4291.       
  4292. display(key%,addr)
  4293. u        
  4294. v6    
  4295.  17:addr=
  4296. shift(0,key%,1):
  4297. display(key%,addr)
  4298. val_help
  4299. save_everything
  4300. store
  4301. z#    
  4302. retrieve(scratchpad$)
  4303. {/    
  4304. filter(wi%,b%,
  4305. selected(wi%,ic%))
  4306.  24,25,26,27:
  4307. ~       
  4308. text(wi%,ic%)=""
  4309.       
  4310.       R$=$
  4311. text(wi%,ic%)
  4312. G      
  4313.  R$="" 
  4314. text(wi%,ic%)=
  4315. (REC%) 
  4316.  addr=
  4317. find("#"+R$,key%,
  4318.         
  4319. redraw_icon(wi%,ic%)
  4320. =    
  4321.  customise% 
  4322. (libfunc$+"_button(wi%,ic%,b%)")
  4323. fkey_status(ic%)
  4324.  Modify% 
  4325.  keynumber%
  4326.  ic%>=0 
  4327.  ic%<23 
  4328.   kpad%=ic%
  4329.  ic%=22 
  4330.  $Kpadicon%="Soptoff;r5,14" 
  4331.  $Kpadicon%=$
  4332. val(keypadW%,ic%)
  4333.   $FkeyTitle%=vname$(ic%+9)
  4334. $  keynumber%=buttonfield%(1,ic%)
  4335.  keynumber%>0 
  4336. -    $Fkeyequiv%="F"+
  4337. (keynumber% 
  4338.  %1111)
  4339. /    
  4340. set_icon(fkeyW%,1,(keynumber% 
  4341.  1<<4))
  4342. /    
  4343. set_icon(fkeyW%,2,(keynumber% 
  4344.  1<<5))
  4345.         
  4346.     $
  4347. text(fkeyW%,3)="None"
  4348. deselect(fkeyW%,1)
  4349. deselect(fkeyW%,2)
  4350. lit(keystrokeM%,0,
  4351. lit(keystrokeM%,0,
  4352. show_menu(keystrokeM%,x%-64,y%)
  4353. load_functionkeys
  4354.  F,I%,d$
  4355. buttonfield%()=0
  4356. (-1) 
  4357.  d$="Initial" 
  4358.  d$="Resources"
  4359. ("<Pbase$Dir>."+d$+".Fkeys")
  4360.   buttonfield%(1,I%)=
  4361.   I%+=1
  4362. close_file(F)
  4363. save_fkeys
  4364.  F,I%
  4365. ("<Pbase$Dir>.Resources.Fkeys")
  4366.  I%=0 
  4367. (buttonfield%(1,I%))
  4368. close_file(F)
  4369. list_fkeys
  4370.  I%,K%,pad%,F,K$,S$
  4371. print_init("W")
  4372. @TextName$=$database%+".PrintJobs.Fkeys":$SaveName%=TextName$
  4373. format$="keys"
  4374. spacer$,"|")>0 
  4375.  spacer$="|"
  4376. ,LenLine%=Lmargin%+39:Tab%(2)=Lmargin%+30
  4377. 8maxhead%=0:fspace%=18:hspace%=3*36-18:PrintFields%=2
  4378. send_title("Keystroke equivalents")
  4379.  "Hourglass_On"
  4380.  I%=0 
  4381.   K%=buttonfield%(1,I%)
  4382.  K%=0 
  4383.     K$="None"
  4384.         
  4385.     K$="F"+
  4386.  %1111)
  4387.     pad%=2
  4388. .    
  4389.  (K% 
  4390.  (1<<4)) 
  4391. (139)+K$:pad%-=1
  4392. +    
  4393.  (K% 
  4394.  (1<<5)) 
  4395.  K$="^"+K$:pad%-=1
  4396. store_string(vname$(I%+9),Lmargin%,
  4397. store_string(K$,Tab%(2)+pad%,
  4398. ,    
  4399.  13:S$=vname$(I%+9)+" all subfiles"
  4400. '    
  4401.  14:S$="Copy displayed record"
  4402. (    
  4403.  18:S$="Turn validation ON/OFF"
  4404. :S$=""
  4405.  S$<>"" 
  4406. $    
  4407. store_string(S$,Lmargin%,
  4408. ,    
  4409. store_string(
  4410. (139)+K$,Tab%(2)+1,
  4411. ("<Pbase$Dir>.Resources.KeyList")
  4412. store_string(
  4413. #F,Lmargin%,
  4414. close_file(F)
  4415.  "Hourglass_Off"
  4416. screen_list
  4417. write_log(-1,"Keystroke equivalents printed","")
  4418. scan(z%,s%)
  4419. stop%=
  4420.    addr=
  4421. moveto(key%,addr,z%)
  4422.   K%=
  4423. complete(4)
  4424.  stop%
  4425. store
  4426.  wi%,ic%
  4427.  printorder$<>"" 
  4428. (-1) 
  4429. to_clipboard
  4430.  "Wimp_GetCaretPosition",,block%
  4431.   wi%=!block%:ic%=block%!4
  4432. !  scratchpad$=$
  4433. text(wi%,ic%)
  4434. to_clipboard
  4435.  I%,L%,P%,len%,S$,b$
  4436. NSHsaveptr%=
  4437. extend_named_sliding_block(saveanchor%,SHclaim%):P%=SHsaveptr%
  4438. clear_mem(SHsaveptr%,0,
  4439. sliding_block_size(saveanchor%))
  4440.  I%=1 
  4441.  printorder$ 
  4442. (  F$=
  4443. printorder$,I%,2):F%=
  4444. ("&"+F$)
  4445.  chartype%(F%) 
  4446. k    
  4447.  0,1,2,3,4,5,6,7,8,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79: 
  4448.     S$=$Rf%(F%):L%+=
  4449. (S$)+1
  4450. 0    SHsaveptr%=
  4451. claim_page(saveanchor%,L%+1)
  4452.     $P%=S$:P%+=
  4453. (S$)+1
  4454.  36,39:
  4455. 3    len%=
  4456. blob_path(
  4457. ,$database%,REC%,F%,39,b$)
  4458.  len%>0 
  4459.       L%+=len%
  4460. 2      SHsaveptr%=
  4461. claim_page(saveanchor%,L%+1)
  4462.        
  4463.  "OS_File",255,b$,P%
  4464.       P%+=len%+1
  4465.             
  4466.  41,42,43,61,62:
  4467. %    S$=$Rf%(F%):Z%=
  4468. no_yes(F%,S$)
  4469.     L%+=
  4470. (S$)+1
  4471. 0    SHsaveptr%=
  4472. claim_page(saveanchor%,L%+1)
  4473.     $P%=S$:P%+=
  4474. (S$)+1
  4475. @Start%=SHsaveptr%:End%=Start%+L%:datasize%=L%:ramptr%=Start%
  4476.  clip% 
  4477. -  block%!0=24:block%!16=15:block%!20=%100
  4478.  "Wimp_SendMessage",17,block%,0
  4479. #  clip%=
  4480. :savefunc$="Clipboard"
  4481. retrieve(S$)
  4482. (-1) 
  4483. request_clipped
  4484.  wi%,ic%,L%
  4485.  "Wimp_GetCaretPosition",,block%
  4486.   wi%=!block%:ic%=block%!4
  4487.  scratchpad$<>"" 
  4488. !"    L%=
  4489. buffer_length(wi%,ic%)
  4490.     $
  4491. text(wi%,ic%)=
  4492. S$,L%)
  4493. #C    
  4494.  F$(Fieldnumber%)<>"" 
  4495. text(wi%,ic%)=F$(Fieldnumber%)
  4496. redraw_icon(wi%,ic%)
  4497. set_caret(0,wi%,ic%)
  4498.  vtype$(chartype%(Fieldnumber%))="L" 
  4499.  ScrollChanged%=
  4500. request_clipped
  4501. ,(!block%=256:block%!12=0:block%!16=16
  4502. - block%!20=mainW%:block%!24=1
  4503. .Fblock%!28=0:block%!32=0:block%!36=%100:block%!40=&fff:block%!44=-1
  4504.  "Wimp_SendMessage",18,block%,0:
  4505.  Broadcast DataRequest
  4506. my_ref%=block%!8:pasting%=
  4507. from_clipboard(f$)
  4508.  wi%,ic%,F%,L%,S$
  4509.  "Wimp_GetCaretPosition",,block%
  4510. wi%=block%!0:ic%=block%!4
  4511.   S$=
  4512.  wi% 
  4513. ;#    
  4514.  mainW%:F%=
  4515. get_field(ic%)
  4516.  chartype%(F%) 
  4517.       
  4518.  0,1,2,3,4,5,8,63:
  4519. >=      $
  4520. text(wi%,ic%)=
  4521. S$,len%(F%)):
  4522. redraw_icon(wi%,ic%)
  4523. ?        
  4524.     F%+=1:ic%=field%(F%)
  4525. A     
  4526.  tableW%(Tablenumber%):
  4527. B"    L%=
  4528. buffer_length(wi%,ic%)
  4529. C5    $
  4530. text(wi%,ic%)=
  4531. S$,L%):
  4532. redraw_icon(wi%,ic%)
  4533.     ic%+=1
  4534. close_file(F)
  4535. H-block%!0=20:block%!12=my_ref%:block%!16=4
  4536.  "Wimp_SendMessage",17,block%
  4537. pasting%=
  4538.  ### Binary Large Objects (B.L.O.B.s) ###
  4539. blob_path(create%,f$,R%,F%,V%,
  4540.  O$,main$,level1$,level2$,d%,dn%,do%,L%,bn$,bo$
  4541.  R%<0 
  4542. softerror("",164):=-1
  4543.  36,39:main$=f$+"."+Tag$(F%)+"text"
  4544.  37,40:main$=f$+"."+Tag$(F%)+"sprite"
  4545.  38:main$=f$+"."+Tag$(F%)+"draw"
  4546.  64,65,66,67:main$=f$+"."+Tag$(F%)+"scroll"
  4547. X"level1$=main$+"."+
  4548.  4900)
  4549. Y"level2$=level1$+"."+
  4550. ZTbn$=level2$+".Rec"+
  4551. (R%):
  4552.  "OS_File",5,bn$ 
  4553.  dn%,,,,Ln%:
  4554.  dn%=1 
  4555.  d%=dn%:L%=Ln%
  4556. [Vbo$=level2$+"."+
  4557.  70):
  4558.  "OS_File",5,bo$ 
  4559.  do%,,,,Lo%:
  4560.  do%=1 
  4561.  d%=do%:L%=Lo%
  4562.  objname$ 
  4563.  "NEW":b$=bn$:
  4564.  do%=1 
  4565.  dn%=0 
  4566.  "OS_CLI","Rename "+bo$+" "+bn$
  4567.  "OLD":b$=bo$:
  4568.  dn%=1 
  4569.  do%=0 
  4570.  "OS_CLI","Rename "+bn$+" "+bo$
  4571.  d%=0 
  4572.  create%=
  4573.  "OS_File",8,main$
  4574.  "OS_File",8,level1$
  4575.  "OS_File",8,level2$
  4576.  d%=1 
  4577. load_blob(f$,R%,F%,V%)
  4578.  L%,b$
  4579. i#L%=
  4580. blob_path(
  4581. ,f$,R%,F%,V%,b$)
  4582.  L%>=0 
  4583. k;  SHmisc%=
  4584. extend_named_sliding_block(tempanchor%,L%+1)
  4585.  "OS_File",255,b$,SHmisc%
  4586. blob_to_file(F,L%)
  4587.  Used only to transfer CSV fields to external files
  4588.  L%>0 
  4589.  "OS_GBPB",2,F,SHmisc%,L%
  4590. copy_blob(source$,dest$,RS%,RD%,F%,V%)
  4591.  L%,Z%,bs$,bd$
  4592. w*L%=
  4593. blob_path(
  4594. ,source$,RS%,F%,V%,bs$)
  4595.  L%>0 
  4596. y*  Z%=
  4597. blob_path(
  4598. ,dest$,RD%,F%,V%,bd$)
  4599.  "OS_CLI","Copy "+bs$+" "+bd$+" ~C~V~Q"
  4600. delete_blob(F%,F$,wi%,ic%)
  4601.  flag%,f$,object$
  4602. selected(prefsW%,20) 
  4603. confirm(
  4604. msg("Err115,"+$RemoveOb%)) 
  4605. (    
  4606.  "OS_CLI","Delete "+F$:flag%=
  4607.  "OS_CLI","Delete "+F$:flag%=
  4608.  flag% 
  4609.  chartype%(F%) 
  4610. 6    
  4611.  36:$
  4612. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssm!edit"
  4613. 7    
  4614.  37:$
  4615. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssm!paint"
  4616. 6    
  4617.  38:$
  4618. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssm!draw"
  4619.  39:$
  4620. text(wi%,ic%)=""
  4621. #    
  4622. show_picture(F%,REC%)
  4623.  64,65,66,67:
  4624. /    
  4625. get_scroller(REC%,F%,chartype%(F%)-63)
  4626. redraw_icon(wi%,ic%)
  4627. asterisk(
  4628. set_blob_sprite(R%,F%,V%,
  4629.  L%,sprite$
  4630.  R%=RA% 
  4631.  L%=-1 
  4632. blob_path(
  4633. ,$database%,R%,F%,V%,b$)
  4634.  L%>=0 
  4635.  sprite$="small_fff" 
  4636.  sprite$="sm!edit"
  4637.  L%>=0 
  4638.  sprite$="small_ff9" 
  4639.  sprite$="sm!paint"
  4640.  L%>=0 
  4641.  sprite$="small_aff" 
  4642.  sprite$="sm!draw"
  4643. val(mainW%,field%(F%))="R5;Pptr_ext,8,4;S"+sprite$
  4644. redraw_icon(mainW%,field%(F%))
  4645. edit_blob(F%,V%)
  4646.  wi%,ic%,b$,O$,val$,F
  4647.  "Wimp_GetCaretPosition",,block%:returnto%=block%!4
  4648. wi%=mainW%:ic%=field%(F%)
  4649.  36:O$="Text":val$="R5;Pptr_ext,8,4;Ssmall_fff":ftype%=&fff:OLE%=F%
  4650.  37:O$="Sprite":val$="R5;Pptr_ext,8,4;Ssmall_ff9":ftype%=&ff9:OLE%=F%
  4651.  38:O$="Draw":val$="R5;Pptr_ext,8,4;Ssmall_aff":ftype%=&aff:OLE%=F%
  4652.  39:O$="Text":val$="L;Pptr_ext,8,4":ftype%=&fff:OLE%=F%
  4653.  40:O$="Sprite":val$="Z0;Pptr_ext,8,4;Ssmall_ff9":ftype%=&ff9:OLE%=F%
  4654. blob_path(
  4655. ,$database%,REC%,F%,V%,b$)<0 
  4656.  V%<>40 
  4657. val(wi%,ic%)=val$
  4658.  "OS_CLI","Copy <PBase$Dir>.Resources.Objects."+O$+" "+b$+" ~C~V"
  4659.  V%=36 
  4660. (b$):
  4661. #F,"Record "+
  4662. (REC%)+": "+$Rf%(KF%(0,0)):
  4663. close_file(F)
  4664. redraw_icon(wi%,ic%)
  4665.  OLE%>0 
  4666.  OLE$=b$:
  4667.  "OS_File",5,b$ 
  4668.  ,,,OLEDS%
  4669.  "OS_CLI","Filer_Run "+b$
  4670. transfer_blob(wi%,ic%,file$,d%,ft%)
  4671.  F%,V%,L%,W%,f$,b$,ok%,list$,c$,name%
  4672.  wi%<>mainW% 
  4673.  Access%=
  4674. #F%=(ic%+1) 
  4675.  2:V%=chartype%(F%)
  4676. "name%=
  4677. text(mainW%,field%(F%))
  4678.  60:f$=
  4679. compare_paths(file$,$database%)
  4680. (f$)<=len%(F%) 
  4681.     $Rf%(F%)=f$   
  4682. -    Z%=
  4683. set_remote_sprite(F%,file$):ok%=
  4684. /    
  4685. softerror(file$+","+
  4686. (len%(F%)),154)
  4687.  ft%=-1 
  4688. .    file$=
  4689. compare_paths(file$,$database%)
  4690. -    link$(F%)="@"+file$:link$(0)="LOADED"
  4691. &    $
  4692. val(wi%,ic%)="R5;Sdirectory"
  4693. 5    
  4694.  WithLeaf% 
  4695.  $name%=
  4696. leaf(file$) 
  4697.  $name%=""
  4698.     ok%=
  4699.  ft%<>-1 
  4700. .    file$=
  4701. compare_paths(file$,$database%)
  4702. -    link$(F%)="@"+file$:link$(0)="LOADED"
  4703. *    $
  4704. val(wi%,ic%)="R5;Sfile_"+
  4705. ~(ft%)
  4706. 5    
  4707.  WithLeaf% 
  4708.  $name%=
  4709. leaf(file$) 
  4710.  $name%=""
  4711.     ok%=
  4712.  ft%=&fff 
  4713. install_blob:$
  4714. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssmall_fff":ok%=
  4715.  ft%=&ff9 
  4716. install_blob:$
  4717. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssmall_ff9":ok%=
  4718.  ft%=&aff 
  4719. install_blob:$
  4720. val(wi%,ic%)="R5;Pptr_ext,8,4;Ssmall_aff":ok%=
  4721.  ft%=&fff 
  4722. install_blob:
  4723. show_text_block(F%,REC%):ok%=
  4724.  ft%=&ff9 
  4725. install_blob:
  4726. show_picture(F%,REC%):ok%=
  4727.  ok% 
  4728. redraw_icon(wi%,ic%):
  4729. asterisk(
  4730. install_blob
  4731. blob_path(
  4732. ,$database%,REC%,F%,V%,b$)
  4733.  "OS_CLI","Remove "+b$
  4734.  "OS_CLI","Copy "+file$+" "+b$+" ~C~V"
  4735. show_text_block(F%,REC%)
  4736.  F,b$,I%,len%,base%
  4737.  F%=0 
  4738. base%=Rf%(F%)
  4739. /len%=
  4740. blob_path(
  4741. ,$database%,REC%,F%,39,b$)
  4742.  len%>0 
  4743.  len%>len%(F%) 
  4744.  len%=len%(F%)
  4745.  ### Load only as much of file as we can display ###
  4746. @  F=
  4747. (b$):
  4748.  F>0 
  4749.  "OS_GBPB",4,F,base%,len%:
  4750. close_file(F)
  4751.  ### Replace any characters<32 by spaces - but ONLY for display ###
  4752.  I%=0 
  4753.  len%-1
  4754. #    
  4755.  base%?I%<32 
  4756.  base%?I%=32
  4757.   base%?len%=10
  4758.  $base%=""
  4759. show_picture(F%,REC%)
  4760.  F,f$,I%,max%,len%,x%,y%,w%,h%,base%
  4761.  F%=0 
  4762. /len%=
  4763. blob_path(
  4764. ,$database%,REC%,F%,40,f$)
  4765. E!block%=mainW%:block%!4=field%(F%):
  4766.  "Wimp_GetIconState",,block%
  4767. <x%=block%!8:y%=block%!12:w%=block%!16-x%:h%=block%!20-y%
  4768.  "Wimp_DeleteIcon",,block%
  4769.  len%>=0 
  4770. 7  base%=
  4771. extend_named_sliding_block(Rf%(F%),len%+4)
  4772. /  !base%=len%+4:
  4773.  "OS_File",255,f$,base%+4
  4774. Q  field%(F%)=
  4775. create_icon(0,mainW%,x%,y%,w%,h%,&0700A53E,"",base%+16,base%,0)
  4776.  base% points to sprite area, base%+16 to sprite itself
  4777. K  field%(F%)=
  4778. create_icon(0,mainW%,x%,y%,w%,h%,&0700A53E,"",paint%,1,8)
  4779.  paint% points to sprite name (File_ff9),1 means wimp pool,8 is name length
  4780. get_remote_file(field%)
  4781.  f$,err%
  4782. filename($Rf%(field%),"PrintRes",-1)
  4783.  f$<>"" 
  4784.  "XOS_File",5,f$ 
  4785.  d%;err%
  4786.  (err% 
  4787.  1)=1 
  4788. 5    
  4789. softerror(f$+","+
  4790. leaf(f$)+","+Tag$(F%),121)
  4791. .    
  4792.  d%>0 
  4793.  "OS_CLI","Filer_Run "+f$
  4794. set_remote_sprite(field%,f$)
  4795.  d%,type%,err%,wi%,ic%,sprite$
  4796. !wi%=mainW%:ic%=field%(field%)
  4797.  f$="" 
  4798.  d%=-1 
  4799.  "XOS_File",5,f$ 
  4800.  d%,,type%;err%
  4801.  (err% 
  4802.  1)=1 
  4803. softerror(f$+","+
  4804. leaf(f$)+","+Tag$(field%),121):d%=0
  4805.  0:sprite$="whatsit":
  4806.  Filename present but file not found
  4807. -1:sprite$="dropfile":
  4808.  No filename in field
  4809.  1:type%=(type%>>8) 
  4810.  &fff:sprite$="file_"+
  4811. ~(type%)
  4812.   c$=
  4813. leaf(f$),1)
  4814.  c$="!" 
  4815.  sprite$="application" 
  4816.  sprite$="directory"
  4817. val(wi%,ic%)="R5;Pptr_ext,8,4;S"+sprite$
  4818. redraw_icon(wi%,ic%)
  4819. filter(wi%,b%,on%)
  4820.  x%,y%,vxmin%,vymax%,scrollx%,scrolly%
  4821.  b%=1 
  4822.  on%=
  4823.  on%=
  4824.  b%=4
  4825. filter%=on%:finished%=
  4826. ->matched%=0:$
  4827. text(filterW%,5)="0":
  4828. redraw_icon(filterW%,5)
  4829.  on% 
  4830.  wi% 
  4831.  keypadW%:
  4832. 24    !block%=wi%:
  4833.  "Wimp_GetWindowState",,block%
  4834. 3=    
  4835. position_window(filterW%,block%!12,block%!8,0,0,0,0)
  4836. 4A    
  4837.  mainW%:
  4838. open_at(firstfilter%,filterW%,22,482,316,44,44)
  4839.  b%=1 
  4840.  $Query%=query$
  4841. set_caret(0,queryW%,0)
  4842. 9B  Filter$="TRUE":
  4843. close_it(filterW%):
  4844. restore_caret(returnto%)
  4845. set_icon(keypadW%,22,on%)
  4846.  field%(buttonfield%(0,22))>0 
  4847. set_icon(mainW%,field%(buttonfield%(0,22)),on%)
  4848. fast_wind(T%,P%,D%)
  4849. A fast%=
  4850. text(keypadW%,23))
  4851. D%=(D%+1) 
  4852.  P%<>T% 
  4853.  I%<fast%
  4854.  filter% 
  4855. next_match(P%,D%,Filter$,Z%) 
  4856. neighbour(key%,P%,D%)
  4857.   I%+=1
  4858.  P%=T% 
  4859.  filter% 
  4860.  7:P%=
  4861. neighbour(key%,P%,1-D%)
  4862.  merging% 
  4863. merge_next(filter%,key%,P%) 
  4864. display(key%,P%)
  4865. subfile(direction%)
  4866. file%+=direction%
  4867.  file%=6 
  4868.  file%=0
  4869.  file%=-1 
  4870.  file%=5
  4871. set_subfile(file%)
  4872.  filemem%(file%,key%)>=0 
  4873. Q3  addr=filemem%(file%,key%):
  4874. display(key%,addr)
  4875.  addr=
  4876. moveto(key%,top,1)
  4877. set_subfile(fi%)
  4878. top=8*fi%+LH%
  4879. Y $Subfilename%=$Subfile%(fi%)
  4880.  ic%=6 
  4881. deselect(queryW%,ic%)
  4882. select(queryW%,fi%+6)
  4883. save_subfilenames
  4884.  present%=7 
  4885. c!  F=
  4886. ($database%+".Subfiles")
  4887.  I%=0 
  4888. #F,$Subfile%(I%)
  4889. close_file(F)
  4890. allow_search(wi%,e%)
  4891. select(searchW%,5):
  4892. deselect(searchW%,6)
  4893. select(searchW%,6):
  4894. deselect(searchW%,5)
  4895. text(searchW%,1)="":
  4896. redraw_icon(searchW%,1)
  4897. text(searchW%,7)="":
  4898. redraw_icon(searchW%,7)
  4899. text(searchW%,3)=Index$(key%)
  4900.  wi% 
  4901.  keypadW%:
  4902. u7  !block%=keypadW%:
  4903.  "Wimp_GetWindowState",,block%
  4904. position_window(searchW%,block%!12,block%!8,0,0,0,0)
  4905.  mainW%:
  4906. open_at(firstsearch%,searchW%,13,456,316,114,52)
  4907. set_caret(0,searchW%,1)
  4908. val_help
  4909.  name$,subst%,field%,extra%,fld%,scrcol%
  4910.  "Wimp_GetCaretPosition",,block%
  4911. wi%=block%!0:ic%=block%!4
  4912. scroller_num2(wi%)
  4913.  wi% 
  4914.  mainW%:fld%=(ic%+1) 
  4915.  scrollerW%(S%):fld%=scrolldata%(S%,0)
  4916.  fld%>0 
  4917.   name$=link$(fld%)
  4918. +  field%=
  4919. trailing_number(name$,exact%)
  4920. +  subst%=
  4921. leading_number(scrcol%,name$)
  4922. '  Tablenumber%=
  4923. table_number(name$)
  4924.  Tablenumber%<>-1 
  4925. show_table(Tablenumber%,0,0) 
  4926.  Tablenumber%=0
  4927. val_on_off(on%)
  4928.  I%=1 
  4929.  on% 
  4930. $    
  4931. :$valid%(I%)=$rvalid%(I%)
  4932. (    
  4933. :$valid%(I%)="Pptr_write,4,4"
  4934. save_click(wi%,ic%,b%)
  4935.  f$,p$,H$
  4936. butt%=(b% 
  4937.  %111)
  4938.  ic%=4 
  4939. text(wi%,ic%) 
  4940.  "Default selection":
  4941. y    
  4942. selected(wi%,ic%) 
  4943.  $SaveName%=$database%+".PrintRes.!Selection" 
  4944.  $SaveName%=$database%+".PrintRes.Selection"
  4945.  "Default query":
  4946. q    
  4947. selected(wi%,ic%) 
  4948.  $SaveName%=$database%+".PrintRes.!Query" 
  4949.  $SaveName%=$database%+".PrintRes.Query"
  4950.  "Default options":
  4951. y    
  4952. selected(wi%,ic%) 
  4953.  $SaveName%=$database%+".PrintRes.!PrintOpts" 
  4954.  $SaveName%=$database%+".PrintRes.PrintOpts"
  4955. redraw_icon(wi%,2)
  4956.  wi% 
  4957.  saveW%:
  4958.   Filename$=$SaveName%
  4959.  savefunc$ 
  4960. #    
  4961.  "New database","Copy as":
  4962. +    $SaveName%=
  4963. force_pling($SaveName%)
  4964. $    Filename$=$SaveName%:Type%=0
  4965. 2    
  4966.  "Save as text":
  4967.  Save report from window
  4968. 4    
  4969.  vrules%>0 
  4970.  vrules%=0:
  4971. add_spacers(Count%)
  4972.     Type%=&fff
  4973. 5    Start%=SHtextptr%:End%=Start%+Count%*LenLine%
  4974. -    
  4975.  "Save list":
  4976.  Create report to file
  4977.      Type%=&fff:savetofile%=
  4978. ;    
  4979.  "Save text":
  4980.  Save Text from button or Text Block
  4981.     Type%=&fff:
  4982. =    len%=
  4983. blob_path(
  4984. ,$database%,REC%,Fieldnumber%,36,f$)
  4985. B    SHsaveptr%=
  4986. extend_named_sliding_block(saveanchor%,len%+1)
  4987. &    
  4988.  "OS_File",255,f$,SHsaveptr%
  4989. *    Start%=SHsaveptr%:End%=Start%+len%
  4990. <    
  4991.  "Save sprite":
  4992.  Save from Sprite button or Picture
  4993.     Type%=&ff9
  4994. =    len%=
  4995. blob_path(
  4996. ,$database%,REC%,Fieldnumber%,37,f$)
  4997. B    SHsaveptr%=
  4998. extend_named_sliding_block(saveanchor%,len%+1)
  4999. &    
  5000.  "OS_File",255,f$,SHsaveptr%
  5001. *    Start%=SHsaveptr%:End%=Start%+len%
  5002. -    
  5003.  "Save draw":
  5004.  Save from Draw button
  5005.     Type%=&aff
  5006. =    len%=
  5007. blob_path(
  5008. ,$database%,REC%,Fieldnumber%,38,f$)
  5009. B    SHsaveptr%=
  5010. extend_named_sliding_block(saveanchor%,len%+1)
  5011. &    
  5012.  "OS_File",255,f$,SHsaveptr%
  5013. *    Start%=SHsaveptr%:End%=Start%+len%
  5014. 1    
  5015.  "Save object":
  5016.  Save from Remote button
  5017. 5    
  5018.  "Save as list":
  5019.  Save Scroller as text list
  5020.     Type%=&fff:
  5021. =    len%=
  5022. blob_path(
  5023. ,$database%,REC%,Fieldnumber%,64,f$)
  5024. B    SHsaveptr%=
  5025. extend_named_sliding_block(saveanchor%,len%+1)
  5026. *    Start%=SHsaveptr%:End%=Start%+len%
  5027. &    
  5028.  "OS_File",255,f$,SHsaveptr%
  5029. *    Start%=SHsaveptr%:End%=Start%+len%
  5030. #    
  5031.  "Save options":Type%=&7f5
  5032.  "Save query":
  5033. =    
  5034.  $Query%="" 
  5035.  $savebuff%=query$ 
  5036.  $savebuff%=$Query%
  5037. B    Start%=savebuff%:End%=Start%+
  5038. ($savebuff%)+1:Type%=&7f4   
  5039. *    
  5040.  "Save selection":
  5041. save_selection
  5042.  "Save table":
  5043. c    z$=
  5044. table_info(Tablenumber%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  5045. P    Start%=SHtabptr%(Tablenumber%):End%=Start%+offset%+Rows%*Rec%:Type%=&7f1
  5046.  "Save form file":
  5047.     Type%=&7f2
  5048. lit(designM%,4,
  5049. lit(designM%,5,
  5050. lit(designM%,7,
  5051. 6    
  5052.  adjust%=
  5053. first_writable>0 
  5054. default_key
  5055. 9    
  5056.  "Export selected":
  5057. export_selected(printorder$)
  5058.  savesubW%:
  5059.  savefunc$ 
  5060.  "Export subset":
  5061. )    $SubName%=
  5062. force_pling($SubName%)
  5063. D    
  5064.  $SubName%=$database% 
  5065.  ic%<>3 
  5066.  moan_err%,
  5067. msg("Err222")
  5068. #    Filename$=$SubName%:Type%=0
  5069. *    
  5070.  "Export CSV":Filename$=$SubName%
  5071.  ic% 
  5072.  (b% 
  5073.  %11110000)>0 
  5074. init_drag(wi%,ic%,5)
  5075. Filename$,".")>0 
  5076. 7    
  5077.  butt%<>2 
  5078. save(Filename$,Type%,Start%,End%)
  5079. .    
  5080. write_log(-1,"File saved:",Filename$)
  5081.  butt%=4 
  5082.       
  5083.  wi%=saveW% 
  5084. $        
  5085.  "Wimp_CreateMenu",,-1
  5086. 7        
  5087. close_it(wi%):
  5088. restore_caret(starthere%)
  5089.       
  5090.         
  5091. softerror("",33)
  5092.  "Wimp_CreateMenu",,-1
  5093. close_it(wi%):
  5094. restore_caret(returnto%)
  5095. force_pling(f$)
  5096. leaf$=
  5097. leaf(f$)
  5098. leaf$,1)<>"!" 
  5099.  leaf$="!"+leaf$
  5100. leaf$=
  5101. leaf$,NameLength%)
  5102.  leaf$="!" 
  5103.  leaf$="!XYZZY"
  5104.  leafnamepath$="" 
  5105. =leaf$ 
  5106. =leafnamepath$+"."+leaf$
  5107. key_click(wi%,ic%,b%)
  5108.  I%,J%,L%,tag$,item$
  5109. butt%=(b% 
  5110.  %111)
  5111. z%=(butt%=1)-(butt%=4)
  5112.  butt% 
  5113.  2,4:
  5114.  ic% 
  5115.  8,9,10,11:
  5116. 3    tag$=$
  5117. text(wi%,ic%+4+3*(ic%-8)):L%=
  5118. (tag$)
  5119. &    fieldsM%=
  5120. field_menu(items%,3)
  5121.         
  5122. (      item$=$
  5123. menu_text(fieldsM%,I%)
  5124.       I%+=1
  5125. %    
  5126. item$,L%)=tag$ 
  5127.  I%>items%
  5128. 6    
  5129.  tag$<>"" 
  5130. tick_one(fieldsM%,0,items%,I%-1)
  5131. A    
  5132. show_pop_up_menu(fieldsM%,wi%,ic%):fieldfunc$=
  5133. (ic%-8)  
  5134.  butt% 
  5135.  1,4:
  5136.  ic% 
  5137. 6    
  5138.  0,1,2,3:
  5139. kcycle(keyfield%(ic%),4*ic%+12,-z%)
  5140. 6    
  5141.  4,5,6,7:
  5142. kcycle(keyfield%(ic%-4),4*ic%-4,z%)
  5143. #    
  5144.  keyfunc$<>"Current key" 
  5145.       keylimit%=0:keylen%=0
  5146.       
  5147.  J%=0 
  5148. *        keylimit%+=len%(keyfield%(J%))
  5149. +        keylen%+=
  5150. text(wi%,4*J%+15))
  5151.       
  5152.       
  5153. !1        
  5154.  keylen%>keylimit%:
  5155. softerror("",26)
  5156. "*        
  5157.  keylen%=0:
  5158. softerror("",105)
  5159.         
  5160.         
  5161.  keyfunc$ 
  5162.           
  5163.  "Primary key":
  5164. &,          
  5165. save_form($database%+".Form")
  5166.           key%=0
  5167. (!          
  5168. copy_keydata(key%)
  5169. ),          RA%=
  5170. ($Records%):f$=$database%
  5171. *(          
  5172. make_empty_index(RA%,0,
  5173. +,          
  5174. save_recs(f$+".Database",RA%)
  5175. ,/          present%=7:
  5176. save_keys:
  5177. save_calcs
  5178. -<          design%=
  5179. :present%=1:
  5180. get_it_in(f$):ramwarn%=
  5181. .2          
  5182.  "New primary key":
  5183. new_tree(file%)
  5184. /4          
  5185.  "Create index":
  5186. create_index(key%,
  5187.         
  5188.       
  5189. 2        
  5190.     keyfunc$=""
  5191. 4B    
  5192.  butt%=4 
  5193. close_window(keyW%):
  5194. restore_caret(returnto%)
  5195. 5;    
  5196. close_window(keyW%):
  5197. restore_caret(returnto%)
  5198. shade_key_icons(con%)
  5199. shade(keyW%,30,con%)
  5200.  I%=0 
  5201. shade(keyW%,I%,con%)
  5202. shade(keyW%,31,con%)
  5203. shade(keyW%,12,
  5204. shade(keyW%,16,
  5205. shade(keyW%,20,
  5206. shade(keyW%,24,
  5207. shade(keyW%,30,con%)
  5208. shade(keyW%,35,con%)
  5209. shade(keyW%,37,con%)
  5210. kcycle(
  5211.  F%,show%,z%)
  5212.  J%=0 
  5213. text(keyW%,show%+J%)=""
  5214. N,F%=
  5215. find_next_valid_field(F%,"index",z%)
  5216.  F%>0 
  5217. P"  $
  5218. text(keyW%,show%)=Tag$(F%)
  5219. Q;  $
  5220. text(keyW%,show%+1)="1":
  5221. set_caret(0,keyW%,show%+1)
  5222. text(keyW%,show%+2)="L"
  5223. S'  $
  5224. text(keyW%,show%+3)=
  5225. (len%(F%))
  5226.  J%=0 
  5227. redraw_icon(keyW%,show%+J%)
  5228. find_next_valid_field(F%,use$,z%)
  5229.  F1%,found%
  5230.   F%+=z%
  5231.  F%>fields% 
  5232.  F%=0
  5233.  F%<0 
  5234.  F%=fields%
  5235.   V%=chartype%(F%)
  5236.  F%>0 
  5237.  use$ 
  5238.       
  5239.  "index":
  5240.       
  5241.  vtype$(V%) 
  5242. e,        
  5243.  "S":found%=(V%<>59):
  5244.  Not Logo
  5245. f9        
  5246.  "C":found%=(V%=6 
  5247.  V%=7):
  5248.  Calc & Comp only
  5249. g9        
  5250.  "X":found%=(V%=60):
  5251.  Remote only (pathname)
  5252. h9        
  5253.  "E":found%=(len%(F%)>0):
  5254.  Not simple labels
  5255.       
  5256.       
  5257.  "help":
  5258.       
  5259.  vtype$(V%) 
  5260. l,        
  5261.  "S":found%=(V%<>59):
  5262.  Not Logo
  5263. m"        
  5264.  "C","T","L":found%=
  5265. nL        
  5266.  "X":found%=(V%=36 
  5267.  V%=39 
  5268.  V%=60):
  5269.  Text, Text block & Remote
  5270. o9        
  5271.  "E":found%=(len%(F%)>0):
  5272.  Not simple labels
  5273.       
  5274. q        
  5275.  found%=
  5276.  found%
  5277. copy_keydata(key%)
  5278.  J%,chars%,pos%,word%,field%
  5279. KL%(key%)=0
  5280.  J%=0 
  5281. {7  chars%=
  5282. text(keyW%,4*J%+15)):KL%(key%)+=chars%
  5283. text(keyW%,4*J%+14) 
  5284.  "L":pos%=0
  5285.  "R":pos%=255
  5286. '    
  5287. :pos%=
  5288. text(keyW%,4*J%+14))
  5289. $  word%=
  5290. text(keyW%,4*J%+13))
  5291.   field%=keyfield%(J%)
  5292. <  KW%(key%,J%)=chars%+(pos%<<8)+(word%<<16)+(field%<<24)
  5293.   KF%(key%,J%)=field%
  5294. #case%(key%)=
  5295. selected(keyW%,30)
  5296. set_keydata(key%)
  5297.  J%,chars%,pos%,word%,field%,W%
  5298.  J%=12 
  5299. text(keyW%,J%)=""
  5300.  J%=0 
  5301.   W%=KW%(key%,J%)
  5302.  W%>0 
  5303. 7    chars%=W% 
  5304.  255:$
  5305. text(keyW%,4*J%+15)=
  5306. (chars%)
  5307.     pos%=(W%>>8) 
  5308.  pos% 
  5309. '      
  5310. text(keyW%,4*J%+14)="L"
  5311. )      
  5312.  255:$
  5313. text(keyW%,4*J%+14)="R"
  5314. )      
  5315. text(keyW%,4*J%+14)=
  5316. (pos%)
  5317.         
  5318. ;    word%=(W%>>16) 
  5319.  255:$
  5320. text(keyW%,4*J%+13)=
  5321. (word%)
  5322. >    field%=KF%(key%,J%):$
  5323. text(keyW%,4*J%+12)=Tag$(field%)
  5324.     keyfield%(J%)=field%
  5325. text(keyW%,29)=
  5326. (key%)
  5327. set_icon(keyW%,30,case%(key%))
  5328. set_icon(keyW%,35,incspace%(key%))
  5329. set_icon(keyW%,37,null%(key%))
  5330. key_select(D%)
  5331.  "Wimp_GetCaretPosition",,block%
  5332. wi%=block%!0:ic%=block%!4
  5333. colour(key%,2)
  5334. !    key%=(key%+1) 
  5335.  (Keys%+1)
  5336.  Index$(key%)<>"" 
  5337.  hide%?KF%(key%,0)<>1
  5338. %    key%-=1:
  5339.  key%<0 
  5340.  key%=Keys%
  5341.  Index$(key%)<>"" 
  5342.  hide%?KF%(key%,0)<>1  
  5343. colour(key%,1)
  5344. set_keydata(key%)
  5345. text(searchW%,3)=Index$(key%):
  5346. redraw_icon(searchW%,3)
  5347. top=8*file%+LH%
  5348.  filemem%(file%,key%)>=0 
  5349. 3  addr=filemem%(file%,key%):
  5350. display(key%,addr)
  5351.  addr=
  5352. moveto(key%,top,1)
  5353. restore_caret(starthere%)
  5354. set_key(index$)
  5355.  k%,I$
  5356.     k%=-1
  5357.  index$="" 
  5358.  index$="PRIMARYKEY"
  5359.   k%+=1
  5360.   I$=
  5361. u(Index$(k%))
  5362.  I$=index$ 
  5363.  I$="TEMPORARY"
  5364.  I$=index$ 
  5365. colour(key%,2)
  5366.   key%=k%
  5367. colour(key%,1)
  5368. set_keydata(key%)
  5369.   addr=
  5370. moveto(key%,top,1)
  5371. softerror(index$,199)
  5372. set_colours(wi%,ic%,b%)
  5373.  I%,col%,C%,V%,J%,d$
  5374.  (b% 
  5375.  %111)=4 
  5376.  z%=1 
  5377.  z%=-1
  5378.  (b% 
  5379.  %111) 
  5380.  1,4:
  5381.  ic% 
  5382. !    
  5383.  0,1,2,3,4,5,6,7,8,9,10:
  5384. @    col%=
  5385. get_icon_cols(wi%,ic%):fg%=col% 
  5386.  16:bg%=col% 
  5387. I    
  5388. selected(wi%,18) 
  5389.  fg%=(fg%+z%+16) 
  5390.  bg%=(bg%+z%+16) 
  5391. '    col%=fg%+bg%*16:fcol%(ic%)=col%
  5392. $    
  5393. set_icon_cols(wi%,ic%,col%)
  5394.  I%=0 
  5395.  Keys%
  5396.       
  5397. colour(I%,2)
  5398. colour(key%,1)
  5399.  I%=1 
  5400.  fields%
  5401. F      
  5402.  link$(I%)<>"" 
  5403. set_icon_cols(mainW%,field%(I%),fcol%(8))
  5404. H      
  5405.  mandatory%?I%=1 
  5406. set_icon_cols(mainW%,field%(I%),fcol%(9))
  5407.       V%=chartype%(I%)
  5408.       
  5409.  vtype$(V%)="L" 
  5410.         C%=V%-63
  5411.         
  5412.  J%=1 
  5413. /          
  5414. colour_scroller(I%,J%,fcol%(10))
  5415.         
  5416.       
  5417. /    
  5418. (-1) 
  5419.  d$="Initial" 
  5420.  d$="Resources"
  5421. 5    
  5422. read_colours("<Pbase$Dir>."+d$+".FieldCols")
  5423. close_window(wi%)
  5424. !    
  5425. selected_esg(wi%,1) 
  5426. 3      
  5427.  13:f$="<Pbase$Dir>.Resources.FieldCols"
  5428. )      
  5429.  14:f$=$database%+".FieldCols"
  5430.         
  5431. write_colours(f$)
  5432. create_click(wi%,ic%,b%,caret%)
  5433.  width%,oldmenu%,oldmenu$,ok%
  5434.  caret%=26 
  5435. shade(wi%,29,
  5436. shade(wi%,30,
  5437. butt%=(b% 
  5438.  %111)
  5439.  butt% 
  5440.  2,4:
  5441.  ic%=36 
  5442. show_pop_up_menu(ftypeM%(menunumber%),wi%,ic%)
  5443.  ic%=44 
  5444.  fieldsM%=
  5445. field_menu(items%,0):
  5446. tick_one(fieldsM%,0,fields%-1,Fieldnumber%-1):
  5447. show_pop_up_menu(fieldsM%,wi%,ic%)
  5448.  butt%=4 
  5449.  z%=1 
  5450.  butt%=1 
  5451.  z%=-1 
  5452.  ic% 
  5453. set_limits(0)
  5454. set_limits(1)
  5455. set_limits(2)
  5456. set_limits(3)
  5457. set_limits(4)
  5458. set_limits(5)
  5459. set_limits(6)
  5460. set_limits(7)
  5461. change_type(-z%,menunumber%)
  5462. change_type(z%,menunumber%)
  5463. create_field(
  5464. ($InsText%),posx%,posy%,0,ok%)
  5465.  chartype%(Fieldnumber%)=33 
  5466.  oldmenu%=
  5467. (Tag$(Fieldnumber%)):oldmenu$=$database%+".Menus."+Tag$(oldmenu%)+"Menu"
  5468. create_field(Fieldnumber%,posx%,posy%,Fieldnumber%,ok%)
  5469. remove_field(Fieldnumber%,
  5470.  14,45,46:
  5471. shade(wi%,13,(
  5472. selected(wi%,14)))
  5473.   F%=
  5474. ($InsText%)
  5475.  F%>0 
  5476.  F%<=fields% 
  5477. (    
  5478.  F%<Fieldnumber% 
  5479.  Z%=-1 
  5480.  Z%=1
  5481. (    
  5482. re_sequence(Fieldnumber%,F%,Z%)
  5483. close_window(wi%)
  5484. D  x%=
  5485. ($boxX%):y%=
  5486. ($boxY%):int%=
  5487. ($Gridsnap%):
  5488. snap(x%,y%,int%)
  5489. swap_fields(Fieldnumber%,
  5490. ($InsText%))
  5491. close_it(wi%)
  5492.  42:$boxW%=
  5493. guess_width(
  5494. ($LenText%),fieldtype%,width%)):
  5495. redraw_icon(wi%,9)
  5496. snap_all
  5497.  50,51,52,53:
  5498. nudge(butt%,ic%)
  5499. update_box
  5500.  (present% 
  5501.  4)=0 
  5502. lit(designM%,2,(fields%>0))
  5503.  ic% 
  5504.  18,29:
  5505.  ok% 
  5506.  butt%=4 
  5507. close_window(wi%)
  5508.  30,39,40:
  5509.  butt%=4 
  5510. close_window(wi%)
  5511.  21,47,24,22,23,48,35,54:
  5512.  ic%=54 
  5513. sformat(wi%,
  5514. sformat(wi%,
  5515. sformat(wi%,full%)
  5516.  ic%=56 
  5517. shade(wi%,ic%,
  5518. -0!block%=wi%:
  5519.  "Wimp_GetWindowState",,block%
  5520.  full% 
  5521. :block%!8=block%!16-730:
  5522.  "Wimp_OpenWindow",,block%
  5523. shade(wi%,56,
  5524. shade(wi%,57,
  5525. :block%!8=block%!16-640:
  5526.  "Wimp_OpenWindow",,block%
  5527. update_box
  5528. shade(createW%,6,
  5529. shade(createW%,63,
  5530.  fieldtype% 
  5531.  0,1,2,3,4,5,6,7,46,47,63:
  5532.  adjust% 
  5533. shade(createW%,6,
  5534.  36,37,38,60:
  5535. shade(createW%,63,
  5536.  $TagText%="" 
  5537.  $TagText%=Tag$(fields%):
  5538. redraw_icon(createW%,5)
  5539. =&num%=(fieldtype%=3 
  5540.  fieldtype%=6)
  5541. shade(createW%,14,num%)
  5542. shade(createW%,45,num%)
  5543. shade(createW%,46,num%)
  5544. shade(createW%,13,num% 
  5545. selected(createW%,14))
  5546. shade(createW%,15,(fieldtype%=3 
  5547.  fieldtype%=47))
  5548. shade(createW%,25,(fieldtype%=3))
  5549. shade(createW%,26,
  5550.  adjust%)
  5551.  $Reformatted%="" 
  5552.  adjust% 
  5553. lit(designM%,3,(fields%>0))
  5554. F $ValText%=vname$(fieldtype%)
  5555. redraw_icon(createW%,28)
  5556. set_scroll_def(F%,cols%,load%,clear%,height%)
  5557.  ic%,col%,P%,F,f$
  5558. shade(createW%,56,cols%>0)
  5559.  col%=1 
  5560. shade(createW%,col%+56,col%<=cols%)
  5561.  col%
  5562.  load%:
  5563. R0  f$=$database%+"."+Tag$(F%)+"scroll.Format"
  5564.  col%=1 
  5565.  cols%
  5566. U"    P%=
  5567. text(createW%,col%+56)
  5568. V!    
  5569.  F>0 
  5570.  $P%=
  5571.  $P%="?"
  5572. W&    
  5573. redraw_icon(createW%,col%+56)
  5574.  col%
  5575. close_file(F)
  5576. Z)  $
  5577. text(createW%,56)=
  5578. (height% 
  5579.  clear%:
  5580.  ic%=56 
  5581. ]:    $
  5582. text(createW%,ic%)="":
  5583. redraw_icon(createW%,ic%)
  5584. set_limits(m%)
  5585.  lit%
  5586. currenttype%=0
  5587. lasttype%=?flist%(m%)
  5588. menunumber%=m%
  5589. lit(ftypeM%(m%),currenttype%)
  5590.   currenttype%+=1
  5591. tick_one(ftypeM%(m%),0,lasttype%-1,currenttype%)
  5592. k+fieldtype%=?(flist%(m%)+currenttype%+1)
  5593. update_box
  5594. change_type(d%,m%)
  5595.   currenttype%+=d%
  5596. s5    
  5597.  currenttype%=lasttype% 
  5598.  currenttype%=0
  5599. t8    
  5600.  currenttype%<0 
  5601.  currenttype%=lasttype%-1
  5602. lit(ftypeM%(m%),currenttype%)
  5603. tick_one(ftypeM%(m%),0,lasttype%-1,currenttype%)
  5604. x+fieldtype%=?(flist%(m%)+currenttype%+1)
  5605. update_box
  5606. passwords(x%,wi%,ic%,b%)
  5607.  ic%=19 
  5608.  (b% 
  5609.  %11110000)>0 
  5610.    Filename$="Log":Type%=&fff
  5611. init_drag(wi%,ic%,5)
  5612. b%=(b% 
  5613.  %111)
  5614.  1,4:
  5615.  ic% 
  5616. %    
  5617.  $Write%="" 
  5618.  $Write%=$Read%
  5619. *    
  5620.  $Manager%="" 
  5621.  $Manager%=$Write%
  5622.     F=
  5623. ($database%+".Data")
  5624. $    S$=
  5625. encrypt($Read%,
  5626. #F,S$
  5627. %    S$=
  5628. encrypt($Write%,
  5629. #F,S$
  5630. '    S$=
  5631. encrypt($Manager%,
  5632. #F,S$
  5633.  I%=9 
  5634. "      
  5635. selected(passW%,I%)
  5636. close_file(F)
  5637. &    ShowTools%=
  5638. selected(passW%,9)
  5639. .    
  5640. lit(mainM%,6,ShowTools% 
  5641.  (Tools%=1))
  5642. ?    
  5643.  printorder$<>"" 
  5644. lit(mainM%,7,
  5645. selected(passW%,13))
  5646. +    
  5647. lit(mainM%,8,
  5648. selected(passW%,13))
  5649. +    
  5650. lit(mainM%,9,
  5651. selected(passW%,13))
  5652. ,    
  5653. lit(mainM%,10,
  5654. selected(passW%,13))
  5655. +    
  5656. lit(mainM%,2,
  5657. selected(passW%,14))
  5658. close_window(aclW%)
  5659. K    
  5660.  b%=4 
  5661. close_window(passW%):
  5662.  x%>=0 
  5663. restore_caret(starthere%)
  5664.  ShowTools% 
  5665. !      
  5666. close_window(keypadW%)
  5667.       
  5668.       
  5669.  x%>=0 
  5670.         
  5671.  Tools% 
  5672. ;          
  5673. position_window(keypadW%,100,50,0,0,0,0)
  5674. &          
  5675. open_window(mainW%)
  5676.         
  5677.       
  5678.         
  5679. asterisk(
  5680.      
  5681. selected(passW%,16) 
  5682. &      
  5683. open_log("<Log$Dir>.Log",
  5684. '      
  5685. close_log("<Log$Dir>.Log")
  5686.         
  5687. 4    
  5688. shade(prefsW%,34,
  5689. selected(passW%,15))
  5690. P    
  5691. selected(passW%,16) 
  5692. write_log(-1,"Logging discontinued","")
  5693. A    $
  5694. text(aclW%,0)="":$
  5695. text(aclW%,1)="":$
  5696. text(aclW%,12)=""
  5697. @    
  5698. deselect(aclW%,
  5699. selected_esg(aclW%,1)):
  5700. select(aclW%,4)
  5701. 1    
  5702. open_window(aclW%):
  5703. set_caret(0,aclW%,0)
  5704. 4    
  5705. restore_window(wi%,remember%+winbuff%(1,1))
  5706. close_window(aclW%)
  5707. M    
  5708.  b%=4 
  5709. close_window(wi%):
  5710. restore_caret(starthere%) 
  5711. redraw(wi%)
  5712. +    
  5713.  "OS_File",5,"<Log$Dir>.Log" 
  5714. O    
  5715.  d%=1 
  5716.  "OS_CLI","Filer_Run <Log$Dir>.Log" 
  5717. softerror("",195)    
  5718.  F,user$,passwd$,ok%
  5719.  ic%=15 
  5720.  (b% 
  5721.  %11110000)>0:
  5722. 8    Filename$="Acl":Type%=&ffd:
  5723. init_drag(wi%,ic%,5)
  5724.  (b% 
  5725.  %111)=1:
  5726. B    
  5727.  "OS_ReadVarVal","Acl$Dir",block%,255 
  5728. ,,L%:block%?L%=13
  5729. softerror($block%,210)
  5730. b%=(b% 
  5731.  %111)
  5732.  ic% 
  5733. !    
  5734. close_window(aclW%)
  5735. #    
  5736. selected_esg(aclW%,1) 
  5737.       
  5738.       user$=$
  5739. text(aclW%,0)
  5740. I      
  5741. confirm(
  5742. msg("Err123,"+user$)) 
  5743. remove_user(user$,
  5744. ):ok%=
  5745.       
  5746.       user$=$
  5747. text(aclW%,0)
  5748.       
  5749. remove_user(user$,
  5750.       
  5751. 3        
  5752. text(aclW%,0)="":
  5753. softerror("",126)
  5754. B        
  5755. text(aclW%,1)<>$
  5756. text(aclW%,12):
  5757. softerror("",108)
  5758. 3        
  5759. text(aclW%,1)="":
  5760. softerror("",125)
  5761.         
  5762. -        user$=
  5763. encrypt($
  5764. text(aclW%,0),
  5765. /        passwd$=
  5766. encrypt($
  5767. text(aclW%,1),
  5768.         
  5769.  acl% 
  5770. "          F=
  5771. ("<Acl$Dir>.Acl")
  5772.           
  5773. $          
  5774. ("<Acl$Dir>.Acl")
  5775.           acl%=
  5776.         
  5777. 6        
  5778. #F,user$,passwd$,
  5779. selected_esg(aclW%,1)-3
  5780.         
  5781. close_file(F)
  5782.         ok%=
  5783.       
  5784.         
  5785. A    $
  5786. text(aclW%,0)="":$
  5787. text(aclW%,1)="":$
  5788. text(aclW%,12)=""
  5789. K    
  5790. redraw_icon(aclW%,0):
  5791. redraw_icon(aclW%,1)::
  5792. redraw_icon(aclW%,12)
  5793. set_caret(0,aclW%,0)
  5794. 6    
  5795.  (b% 
  5796.  %111)=4 
  5797.  ok%=
  5798. close_window(aclW%)
  5799. remove_user(u$,remove%)
  5800.  user$,id$,p%,p%,ptr%,F,found%
  5801.  u$<>"" 
  5802.   user$=
  5803. encrypt(u$,
  5804.  acl% 
  5805.     F=
  5806. ("<Acl$Dir>.Acl")
  5807.         
  5808.       ptr%=
  5809.       
  5810. #F,id$,p$,p%
  5811.       found%=(id$=user$)
  5812.  found% 
  5813.  found% 
  5814. 1      
  5815. #F=ptr%:
  5816. (id$),"Z"),
  5817. (p$),"Z"),0
  5818. *      
  5819.  remove% 
  5820. softerror(u$,124)
  5821.         
  5822. close_file(F)
  5823. open_log(f$,resume%)
  5824.  "OS_File",5,f$ 
  5825.  d%=1 
  5826.   loghandle%=
  5827. #loghandle%=
  5828. #loghandle%
  5829.  resume% 
  5830. #loghandle%,"Logging resumed "+
  5831. #loghandle%,"Log opened "+
  5832. #loghandle%,"Database: "+$database%
  5833. .  loghandle%=
  5834. (f$):
  5835.  "OS_File",18,f$,&fff
  5836. #loghandle%,"Log started "+
  5837. #loghandle%,"Database: "+$database%
  5838.  acl% 
  5839. #loghandle%,"User: "+user$
  5840. #loghandle%,"Password level used: "+
  5841. (pw%)
  5842. #loghandle%,
  5843. 35,"-")
  5844. close_file(loghandle%)
  5845. logging%=
  5846. close_log(f$)
  5847.  logging% 
  5848.   loghandle%=
  5849. #loghandle%=
  5850. #loghandle%
  5851. #loghandle%,
  5852. 35,"-")
  5853. #loghandle%,"Log closed "+
  5854. #loghandle%,
  5855. 35,"=")
  5856. close_file(loghandle%)
  5857.   logging%=
  5858. write_log(record%,S$,T$)
  5859.  loghandle%
  5860.  logging% 
  5861. "#  loghandle%=
  5862. ("<Log$Dir>.Log")
  5863. #loghandle%=
  5864. #loghandle%
  5865.  record%>=0 
  5866. #loghandle%,"    [Record number: "+
  5867. (record%)+"]"
  5868. #loghandle%,"    "+S$
  5869.  T$<>"" 
  5870. #loghandle%,"  "+T$
  5871. close_file(loghandle%)
  5872. count(key%,
  5873.  RU%)
  5874.  zero%,file%,top,sum%
  5875. -    RU%=0
  5876.  file%=0 
  5877.   top=8*file%+LH%
  5878. 0"  sum%=
  5879. count_recs(key%,zero%)
  5880.   RU%+=sum%
  5881. 2%  $
  5882. text(miscW%,file%+22)=
  5883. (sum%)
  5884.  file%
  5885. count_recs(key%,
  5886.  ptr%)
  5887.  P%,count%,S%,R%,S$,k$
  5888.  "Hourglass_On"
  5889. neighbour(key%,top,1)
  5890.  P%<>top
  5891.   count%+=1
  5892.  ptr%>0 
  5893.     R%=
  5894. rec_no(k$,key%,P%)
  5895. >#    
  5896.  R%>highest% 
  5897.  highest%=R%
  5898. ?1    !ptr%=R%:$(ptr%+4)=k$:ptr%+=4+KL%(key%)+1
  5899.     SHflag%?R%=0
  5900.   P%=
  5901. neighbour(key%,P%,1)
  5902.  "Hourglass_Off"
  5903. =count%
  5904. analyse(func%)
  5905.  L%,S%,pos%,N%,values%,key%,S$,title$
  5906.  S$(),N%(),R%()
  5907. print_init("W")
  5908. format$="analyse"
  5909.  func%<0 
  5910.  L%=6 
  5911.  key%=func%:L%=KL%(key%)
  5912.  L%>8 
  5913.  Tab%(2)=Lmargin%+L%+6 
  5914.  Tab%(2)=Lmargin%+14
  5915. spacer$,"|")>0 
  5916.  spacer$="|"
  5917. O8maxhead%=0:fspace%=18:hspace%=5*36-18:PrintFields%=2
  5918. Tab%(3)=Tab%(2)+6
  5919. LenLine%=Tab%(3)+6
  5920.  func%<0 
  5921. S%  title$="Analysis of date field"
  5922. T$  S$="Name: "+Tag$(Fieldnumber%)
  5923.   Heading$="Month"
  5924. VV  TextName$=$database%+".PrintJobs.DateAn"+Tag$(Fieldnumber%):$SaveName%=TextName$
  5925. X   title$="Analysis of index"
  5926.   S$="Name: "+Index$(key%)
  5927.   Heading$="Contents"
  5928. [U  TextName$=$database%+".PrintJobs.IndAn"+Tag$(Fieldnumber%):$SaveName%=TextName$
  5929. end_line
  5930. send_title(title$)
  5931. send_title(S$)
  5932. send_title(
  5933. store_string(Heading$,Lmargin%,
  5934. store_rec_num(-2):
  5935. store_string(" Number",Tab%(2),
  5936.  "Hourglass_On"
  5937.  func%<0 
  5938. analyse_date 
  5939. analyse_index
  5940.  "Hourglass_Off"
  5941. store_string("Total",Lmargin%,
  5942. store_rec_num(-2):
  5943. store_string(
  5944. justify(
  5945. (N%),3,2,""),Tab%(2),
  5946. screen_list
  5947. analyse_index
  5948.  P%,ptr%,K$,k%
  5949. K$="***"
  5950. neighbour(key%,top,1)
  5951.  P%<>top
  5952.     R%=
  5953. rec_no(k$,key%,P%)
  5954. u#    
  5955.  k$<>K$ 
  5956.  values%+=1:K$=k$
  5957. v     P%=
  5958. neighbour(key%,P%,1)
  5959.  S$(values%),N%(values%),R%(values%)
  5960. K$="***"
  5961. neighbour(key%,top,1)
  5962.  P%<>top
  5963.     R%=
  5964. rec_no(k$,key%,P%)
  5965.  k$<>K$ 
  5966. ~:      ptr%+=1:K$=k$:S$(ptr%)=K$:N%(ptr%)=1:R%(ptr%)=R%
  5967.       
  5968.  N%(ptr%)+=1
  5969.         
  5970.      P%=
  5971. neighbour(key%,P%,1)
  5972.  I%=1 
  5973.  ptr%
  5974. U  S$=S$(I%):
  5975.  S$="" 
  5976.  S$="<null>" 
  5977.  isadate% 
  5978. transform_date(KL%(key%),S$)
  5979.   S$=
  5980. stripright(S$,"#")
  5981. store_rec_num(R%(I%))
  5982. store_string(S$,Lmargin%,
  5983. store_string(
  5984. justify(
  5985. (N%(I%)),3,2,""),Tab%(2),
  5986.   N%+=N%(I%)
  5987. store_string("No. of values",Lmargin%,
  5988. store_rec_num(-2)
  5989. store_string(
  5990. justify(
  5991. (values%),3,2,""),Tab%(2),
  5992. analyse_date
  5993.  S$(12),N%(12)
  5994. YS$()="<null>","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
  5995. *dbasehandle%=
  5996. ($database%+".Database")
  5997. neighbour(key%,top,1)
  5998.  P%<>top
  5999.   R%=
  6000. rec_no(k$,key%,P%)
  6001. readsmarray(dbasehandle%,R%)
  6002.   S$=F$(Fieldnumber%)
  6003.  S$<>"" 
  6004.     M%=
  6005. S$,4,2))
  6006.     N%(M%)+=1
  6007.  N%(0)+=1
  6008.   P%=
  6009. neighbour(key%,P%,1)
  6010. close_file(dbasehandle%)
  6011.  I%=0 
  6012. store_string(S$(I%),Lmargin%,
  6013. store_string(
  6014. justify(
  6015. (N%(I%)),3,2,""),Tab%(2),
  6016.   N%+=N%(I%)
  6017. update_stats
  6018. $filesize%=
  6019. (RA%)
  6020. $Records%=
  6021. (RA%)
  6022. $used%=
  6023. (RU%)
  6024. #$percent%=
  6025. (RU%*100/RA%))+"%"
  6026.  Keypress processing --------------------------------------------------
  6027. set_keyboard(wi%,ic%)
  6028.  flag%,T%
  6029. selected(prefsW%,21) 
  6030.  T%=0 
  6031.  LastTable%
  6032.  wi%=tableW%(T%) 
  6033.  flag%=
  6034.  flag% 
  6035.  oldwindow%=wi%:oldicon%=ic%
  6036.  wi% 
  6037.  mainW%:
  6038.  chartype%((ic%+1) 
  6039. $    
  6040.  2,4:
  6041.  "OS_Byte",202,0,239
  6042. !    
  6043.  "OS_Byte",202,16,111
  6044.  accessW%:
  6045.  uc% 
  6046.  "OS_Byte",202,0,239 
  6047.  "OS_Byte",202,caps%,111
  6048.  "OS_Byte",202,caps%,111
  6049.  "OS_Byte",118
  6050. process_key
  6051.  wi%,ic%
  6052.  printing% 
  6053.  indexing% 
  6054.  N$,T%
  6055.  "Wimp_GetCaretPosition",,block%
  6056. 4wi%=block%!0:ic%=block%!4:key_pressed%=block%!24
  6057.  T%=0 
  6058.  LastTable%
  6059.  wi%=tableW%(T%) 
  6060.  Tablenumber%=T%
  6061. !Scroller%=
  6062. scroller_num2(wi%)
  6063.  key_pressed% 
  6064. store
  6065. retrieve(scratchpad$)
  6066.  wi% 
  6067.  mainW%:
  6068. main_press(wi%,ic%)
  6069.  passW%:
  6070. dbox_press(4,18,0,0,0)
  6071.  aclW%:
  6072. dbox_press(9,11,0,0,0)
  6073.  changeW%:
  6074. dbox_press(3,6,queryW%,0,0)
  6075.  tabcreateW%:
  6076. dbox_press(2,3,scrollW%,0,MaxCols%*2+1)
  6077.  scrollW%:
  6078. scroll_press
  6079.  saveW%,savesubW%:
  6080. dbox_press(1,3,0,0,0)
  6081.  tableW%(Tablenumber%):
  6082. table_press(Tablenumber%)
  6083.  scrollerW%(Scroller%):
  6084. scroller_press(wi%,ic%,Scroller%,key_pressed%)
  6085.  printW%:
  6086. dbox_press(12,33,0,0,0)
  6087.  printerW%:
  6088. dbox_press(44,67,0,0,0)
  6089.  createW%:
  6090. create_press
  6091.  accessW%:
  6092. dbox_press(3,2,0,0,0)
  6093.  keyW%:
  6094. dbox_press(31,36,0,0,0)
  6095.  matchW%:
  6096. dbox_press(0,6,0,0,0)
  6097.  moveW%:
  6098. dbox_press(1,3,0,0,0)
  6099.  calcW%:
  6100. dbox_press(1,-1,0,0,0)
  6101.  mergeW%:
  6102. dbox_press(4,5,0,0,0)
  6103.  mergebaseW%:
  6104. dbox_press(1,9,0,0,0)
  6105.  reformW%:
  6106. dbox_press(2,1,0,0,0)
  6107.  sizeW%:
  6108. dbox_press(4,5,0,0,0)
  6109.  csvW%:
  6110. dbox_press(9,10,0,0,0)
  6111.  prefsW%:
  6112. dbox_press(39,40,0,0,0)
  6113.  searchW%:
  6114.  key_pressed%=15 
  6115. #    
  6116. search_click(searchW%,9,4)
  6117. !    
  6118. dbox_press(8,10,0,0,0)
  6119.  helpW%:
  6120. dbox_press(7,20,0,0,0)
  6121.  queryW%:
  6122. query_press(oldquery%)
  6123.  inputW%:
  6124. dbox_press(2,3,0,0,0):
  6125.  $Params%="" 
  6126. set_caret(0,wi%,1)
  6127.  keypadW%:
  6128.  customise% 
  6129. (libfunc$+"_press(wi%,ic%)")
  6130.  key_pressed% 
  6131.  13,384,398,399:
  6132.  Ignore these
  6133. query_press(wi%)
  6134.  key_pressed% 
  6135.  wi% 
  6136. .    
  6137.  matchW%,filterW%:
  6138. mouse(0,0,4,wi%,0)
  6139. $    
  6140.  moveW%:
  6141. mouse(0,0,4,wi%,1)
  6142. &    
  6143.  changeW%:
  6144. mouse(0,0,4,wi%,3)
  6145. '    
  6146.  savesubW%:
  6147. set_caret(0,wi%,2)
  6148. query_click(queryW%,2,4)
  6149. shut_window(wi%):
  6150. restore_caret(starthere%)
  6151.  384:
  6152.  wi%<>matchW% 
  6153. match(0,0):
  6154. set_caret(0,queryW%,0)
  6155.  398:
  6156.  wi% 
  6157. &    
  6158.  changeW%:
  6159. set_caret(0,wi%,0)
  6160. '    
  6161.  savesubW%:
  6162. set_caret(0,wi%,2)
  6163.  399:
  6164.  wi% 
  6165. &    
  6166.  changeW%:
  6167. set_caret(0,wi%,1)
  6168. '    
  6169.  savesubW%:
  6170. set_caret(0,wi%,2)
  6171.  416:
  6172. select(printW%,32):
  6173. deselect(printW%,31)
  6174. position_window(printW%,0,0,0,0,0,0)
  6175. set_caret(0,printW%,26)  
  6176.  385,386,387,388,389,390,391,392,393,401,402,403,404,405,406,407,408,409,417,418,419,420,421,422,423,424,425,458,474,490,459,475,491,507:
  6177. button_action(key_pressed%)
  6178.  "OS_Byte",228,1:
  6179.  "Wimp_ProcessKey",key_pressed%
  6180. main_press(wi%,ic%)
  6181. selected(passW%,10) 
  6182.  "Wimp_ProcessKey",key_pressed%:
  6183.  icon%
  6184.  flash% 
  6185. set_icon(wi%,field%(flash%),state%):flash%=
  6186. trim(wi%,ic%)
  6187. validate(Fieldnumber%,T%,N$)=
  6188. "(changed%=
  6189. update_calcs(Fieldnumber%)
  6190.  key_pressed% 
  6191. select_range(1,fields%,
  6192. (-1) 
  6193.  S$="ALL" 
  6194.  S$="TOTALS"
  6195.  Modify% 
  6196. balance(key%):
  6197. print_tree(key%,S$):
  6198. rectify_address(key%)
  6199.  len%(Fieldnumber%)>=10 
  6200. )+    $Rf%(Fieldnumber%)=
  6201. convert_date(4)
  6202. *G    
  6203.  len%(Fieldnumber%)>=8 
  6204.  $Rf%(Fieldnumber%)=
  6205. convert_date(2)
  6206. redraw_icon(wi%,field%(Fieldnumber%))
  6207. check_record 
  6208.  template%=1:
  6209. display(key%,-1)
  6210. /5  fieldsM%=
  6211. field_menu(items%,2+(printorder$=""))
  6212. tick_one(fieldsM%,0,fields%-1,Fieldnumber%-1)
  6213.  "Wimp_GetPointerInfo",,block%
  6214. show_menu(fieldsM%,!block%-150,block%!4+16)
  6215.   fieldfunc$="CtrlF"
  6216. 5(  $ChangeTitle%="Field: "+Fieldname$
  6217. position_window(changeW%,0,0,0,0,0,0):
  6218. set_caret(0,changeW%,0)
  6219.  "OS_CLI","Filer_OpenDir "+$database%+".Indexes"
  6220. set_up_field_menu
  6221. :A  keyfunc$="Create index":$KeyTitle%=keyfunc$+": "+Fieldname$
  6222. shade_key_icons(
  6223. deselect(keyW%,30):
  6224. deselect(keyW%,35):
  6225. deselect(keyW%,37)
  6226. position_window(keyW%,0,0,0,504,0,0):
  6227. set_caret(0,keyW%,13)
  6228. ?0  keyfunc$="Current key":$KeyTitle%=keyfunc$
  6229. set_keydata(key%):
  6230. shade_key_icons(
  6231. position_window(keyW%,0,0,0,504,0,0)
  6232. set_up_field_menu:
  6233.  LastTable%<>-1 
  6234. position_window(linkW%,0,0,0,0,0,0)
  6235. (-2) 
  6236. (-102) 
  6237.     markpane%=
  6238.  markpane%
  6239.  markpane% 
  6240. G9      !block%=mainW%:
  6241.  "Wimp_GetWindowState",,block%
  6242. H@      
  6243. update_pane(markW%,0,block%!16-block%!8+2,696,62,0,0)
  6244. I9      
  6245. close_window(markW%):
  6246. mark_click(markW%,1,4)
  6247. J        
  6248. L&    
  6249.  Fieldnumber%=Lastwritable% 
  6250. M!      
  6251. close_window(relateW%)
  6252. N-      
  6253. check_record 
  6254. display(key%,-1)
  6255.       
  6256. P5      Fieldnumber%=
  6257. next_editable(Fieldnumber%,1)
  6258. Q        
  6259. R,    
  6260. selected(prefsW%,19) 
  6261. relations
  6262. (-1) 
  6263. VC    
  6264. lit(printM%,5) 
  6265. position_window(pselectW%,0,0,0,0,0,0)
  6266. W3    
  6267. position_window(extracalcW%,0,0,0,0,0,0)
  6268. X4    calc%=Ecalc%:
  6269. set_up_calc(extracalcW%,calc%)
  6270.  filter% 
  6271. \T    
  6272.  field%(buttonfield%(0,22))>0 
  6273. filter(mainW%,4,
  6274. filter(keypadW%,4,
  6275. ].    
  6276. selected(passW%,14) 
  6277. match(0,0)
  6278. query_click(queryW%,2,4)
  6279.  "OS_CLI","Filer_OpenDir "+$database%+".PrintJobs"
  6280.  "OS_CLI","Filer_OpenDir "+$database%+".ValTables"
  6281.  "OS_CLI","Filer_OpenDir "+$database%+".PrintRes"
  6282.  19:starthere%=field%(Fieldnumber%):$StartHere%=Tag$(Fieldnumber%):
  6283. redraw_icon(prefsW%,45):
  6284.  Access% 
  6285. set_caret(0,mainW%,starthere%)
  6286.  len%(Fieldnumber%)>=8 
  6287.     T$=
  6288. g-    
  6289. T$,3,1)=$timesep%:
  6290. T$,6,1)=$timesep%
  6291.     $Rf%(Fieldnumber%)=T$
  6292. i.    
  6293. redraw_icon(wi%,field%(Fieldnumber%))
  6294. get_winpos
  6295. selected(passW%,13) 
  6296. n:    x%=(ScreenWidth%-w%) 
  6297.  2:y%=(ScreenHeight%-h%) 
  6298. o,    choice$(2)="Export":
  6299. act_on_csv_menu
  6300. clear_selection
  6301. keypad_click(keypadW%,1,4)
  6302. close_it(linkW%):
  6303. close_it(keyW%):
  6304. close_it(csvW%)
  6305.  30:Fieldnumber%=
  6306. first_writable:
  6307. set_caret(0,wi%,field%(Fieldnumber%))
  6308.  384:
  6309. selected(passW%,14) 
  6310. x6    
  6311.  qbe% 
  6312. mouse(0,0,4,matchW%,0) 
  6313. match(0,0)
  6314.  394:
  6315.  ShowTools% 
  6316. open_window(keypadW%)
  6317.  398:Fieldnumber%=
  6318. next_editable(Fieldnumber%,1)
  6319. selected(prefsW%,19) 
  6320. relations
  6321.  399:Fieldnumber%=
  6322. next_editable(Fieldnumber%,-1)
  6323. selected(prefsW%,19) 
  6324. relations
  6325.  400:
  6326. mouse(0,0,4,matchW%,0):
  6327. clear_selection
  6328.  416:
  6329. select(printW%,32):
  6330. deselect(printW%,31)
  6331. position_window(printW%,0,0,0,0,0,0)
  6332. set_caret(0,printW%,26)
  6333.  385,386,387,388,389,390,391,392,393,401,402,403,404,405,406,407,408,409,417,418,419,420,421,422,423,424,425,458,474,490,459,475,491,507:
  6334. button_action(key_pressed%)
  6335.  433:
  6336. reveal(
  6337.  434:
  6338. reveal(
  6339.  441:
  6340. protect(wi%,ic%,Fieldnumber%)
  6341.  "OS_Byte",228,1:
  6342.  "Wimp_ProcessKey",key_pressed%
  6343. selected(prefsW%,21) 
  6344.  chartype%(Fieldnumber%) 
  6345. $    
  6346.  2,4:
  6347.  "OS_Byte",202,0,239
  6348. !    
  6349.  "OS_Byte",202,16,111
  6350.  "OS_Byte",118
  6351.  "OS_Byte",15,0
  6352. next_editable(F%,z%)
  6353.  S%,V%,row%,V$,end%
  6354.   F%+=z%
  6355.  F%>fields% 
  6356.  F%=1
  6357.      
  6358.  F%<1 
  6359.  F%=fields%
  6360. 3  V%=chartype%(F%):V$=vtype$(V%):ic%=field%(F%)
  6361.  ((V$="E" 
  6362.  len%(F%)>0) 
  6363.  V$="L")  
  6364. get_icon_cols(wi%,ic%)<>winback%*17
  6365.  "E":
  6366.   wi%=mainW%
  6367. set_caret(0,wi%,ic%)
  6368.  "L":
  6369.   S%=
  6370. scroller_number(F%)
  6371.   wi%=scrollerW%(S%)
  6372.  z%=1 
  6373.     ic%=0:row%=0
  6374.         
  6375.     ic%=scrolldata%(S%,6)-1
  6376. 2    row%=scrolldata%(S%,6) 
  6377.  scrolldata%(S%,8)
  6378.     end%=
  6379. set_caret(0,wi%,ic%)
  6380. scroll_it(wi%,row%,end%)
  6381. user_menu(F%)
  6382. button_action(K%)
  6383.  wi%,ic%,e%,flag%
  6384. button%=
  6385. key_assigned(K%)
  6386.  button%=-1 
  6387.  "Wimp_ProcessKey",K%:
  6388.  ### No keypad action ###
  6389.  button% 
  6390.  23:e%=-1:button%=13
  6391.  24:button%=14:flag%=
  6392.  28:button%=18:flag%=
  6393.  Alter button% so that correct ic% is calculated
  6394.  ShowTools% 
  6395. :ic%=button%:wi%=keypadW%
  6396. :ic%=field%(buttonfield%(0,button%)):wi%=mainW%
  6397.  flag% 
  6398.  button%+=10
  6399.  Put button% back as it was
  6400.  button% 
  6401. invert(wi%,ic%):
  6402. filter(wi%,4,
  6403. selected(wi%,ic%))
  6404. invert(wi%,ic%):
  6405. allow_search(wi%,e%):
  6406. invert(wi%,ic%)
  6407. invert(wi%,ic%):
  6408. display(key%,-2):
  6409. invert(wi%,ic%)
  6410. invert(prefsW%,21)
  6411. val_on_off(
  6412. selected(prefsW%,21))
  6413.  ic%>0 
  6414. shade(wi%,ic%,
  6415. selected(prefsW%,21))
  6416. shaded(wi%,ic%) 
  6417. 1    
  6418.  wi%=keypadW% 
  6419.  ic%>0 
  6420. invert(wi%,ic%)
  6421. &    
  6422. mouse(0,0,4,keypadW%,button%)
  6423. 1    
  6424.  wi%=keypadW% 
  6425.  ic%>0 
  6426. invert(wi%,ic%)
  6427. key_assigned(pressed%)
  6428.     I%=-1
  6429.   I%+=1
  6430.  I%=28 
  6431.  buttonfield%(1,I%)=pressed%
  6432.  buttonfield%(1,I%)=pressed% 
  6433. dbox_press(ok%,esc%,wi2%,down%,up%)
  6434. trim(wi%,ic%)
  6435.  wi% 
  6436.  accessW%:
  6437.  key_pressed% 
  6438. M    
  6439. next_writable(wi%,ic%,1,1,wi2%,down%) 
  6440. mouse(0,0,4,wi%,ok%)
  6441. #    
  6442. mouse(0,0,4,wi%,esc%)
  6443. 7    
  6444.  398:f%=
  6445. next_writable(wi%,ic%,1,0,wi2%,down%)
  6446. 6    
  6447.  399:f%=
  6448. next_writable(wi%,ic%,-1,0,wi2%,up%)
  6449. +    
  6450.  "Wimp_ProcessKey",key_pressed%
  6451.  key_pressed% 
  6452. selected(prefsW%,41) 
  6453. next_writable(wi%,ic%,1,1,wi2%,down%) 
  6454. mouse(0,0,4,wi%,ok%):
  6455. restore_caret(starthere%)
  6456. >    
  6457. mouse(0,0,4,wi%,esc%):
  6458. restore_caret(starthere%)
  6459. 7    
  6460.  398:f%=
  6461. next_writable(wi%,ic%,1,0,wi2%,down%)
  6462. 6    
  6463.  399:f%=
  6464. next_writable(wi%,ic%,-1,0,wi2%,up%)
  6465. #    
  6466.  wi%=tabcreateW% 
  6467.  ic%=0 
  6468. :      $tabcol%=
  6469. (MaxCols%):
  6470. redraw_icon(tabcreateW%,8)
  6471. ;      !block%=scrollW%:
  6472.  "Wimp_GetWindowState",,block%
  6473. =      block%!24=-MaxCols%*44:
  6474.  "Wimp_OpenWindow",,block%
  6475.         
  6476.  385,386,387,388,389,390,391,392,393,401,402,403,404,405,406,407,408,409,417,418,419,420,421,422,423,424,425,458,474,490,506,459,475,491,507:
  6477. $    
  6478. button_action(key_pressed%)
  6479. >    
  6480.  "OS_Byte",228,1:
  6481.  "Wimp_ProcessKey",key_pressed%
  6482. scroll_press
  6483.  row%
  6484. trim(wi%,ic%)
  6485.  key_pressed% 
  6486.  13,398:f%=
  6487. next_writable(wi%,ic%,1,0,tabcreateW%,0)
  6488.  399:f%=
  6489. next_writable(wi%,ic%,-1,0,tabcreateW%,8)
  6490.  "Wimp_ProcessKey",key_pressed%
  6491.  "Wimp_GetCaretPosition",,block%
  6492.  !block%=scrollW% 
  6493.  ic%=block%!4 
  6494.  ic%=0
  6495. row%=ic% 
  6496. 0$tabcol%=
  6497. (row%):
  6498. redraw_icon(tabcreateW%,8)
  6499. scroll_it(scrollW%,row%,
  6500. table_press(T%)
  6501.  icons%,row%,scrollrow%,visible_rows%
  6502. trim(wi%,ic%)
  6503. icons%=Rows%*(TabFields%+1)
  6504.  key_pressed% 
  6505.  ic%<icons%-1 
  6506.  ic%+=1 
  6507.  ic%=0
  6508.  398:
  6509.  ic%<icons%-TabFields%-1 
  6510.  ic%+=(TabFields%+1) 
  6511.  ic%=ic% 
  6512.  (TabFields%+1)
  6513.  399:
  6514.  ic%>=TabFields%+1 
  6515.  ic%-=(TabFields%+1) 
  6516.  ic%=icons%-TabFields%-1+ic% 
  6517.  (TabFields%+1)
  6518.  "Wimp_ProcessKey",key_pressed%
  6519. set_caret(0,tableW%(T%),ic%)
  6520. 'row%=(ic% 
  6521.  (TabFields%+1))-NewTab%
  6522. 8!block%=tableW%(T%):
  6523.  "Wimp_GetWindowState",,block%
  6524. -visible_rows%=(block%!16-block%!8) 
  6525.  44-1
  6526.  scrollrow%=-(block%!24 
  6527.  row%-scrollrow%>visible_rows% 
  6528.  block%!24=(visible_rows%-row%)*44:
  6529.  "Wimp_OpenWindow",,block%
  6530.  row%<scrollrow% 
  6531.  block%!24=-row%*44:
  6532.  "Wimp_OpenWindow",,block%
  6533. create_press
  6534. shaded(wi%,29):
  6535. shaded(wi%,18) 
  6536. dbox_press(18,41,0,0,0)
  6537. shaded(wi%,29) 
  6538. dbox_press(29,41,0,0,0)
  6539. menu_select
  6540.  P%,Q%,I%,M%,field%,umenu%
  6541. (&choice1%=!block%:choice2%=block%!4
  6542. )(choice3%=block%!8:choice4%=block%!12
  6543.  menuhandle% 
  6544.  fontM%:
  6545.  "Font_DecodeMenu",,fontM%,block%,block%+255,255
  6546.  "Wimp_DecodeMenu",,menuhandle%,block%,choices%
  6547.  I%=1 
  6548.   Q%=
  6549. $choices%,".",P%+1)
  6550. 1&  choice$(I%)=
  6551. $choices%,P%,Q%-P%)
  6552.   P%=Q%+1
  6553.  "Wimp_GetPointerInfo",,block%
  6554. x%=!block%:y%=block%!4
  6555. redo%=block%!8=1
  6556.  menuhandle% 
  6557.  fontM%:
  6558. display_font_name(
  6559. getstr(block%+255))
  6560.  iconbarM%:
  6561. act_on_icon_bar_menu
  6562.  mainM%:
  6563. act_on_main_menu
  6564.  designM%:
  6565. act_on_create_menu
  6566.  tableM%:
  6567. act_on_table_menu(choice$(1))
  6568.  listM%:
  6569. act_on_text_menu
  6570.  delimiterM%:
  6571. act_on_csv_sep
  6572.  terminatorM%:
  6573. act_on_csv_term
  6574.  scrolltermM%:
  6575. act_on_csv_scrollterm
  6576.  markM%:
  6577. act_on_mark_menu
  6578.  ftypeM%(0):
  6579. act_on_fieldtype_menus(0)
  6580.  ftypeM%(1):
  6581. act_on_fieldtype_menus(1)
  6582.  ftypeM%(2):
  6583. act_on_fieldtype_menus(2)
  6584.  ftypeM%(3):
  6585. act_on_fieldtype_menus(3)
  6586.  ftypeM%(4):
  6587. act_on_fieldtype_menus(4)
  6588.  ftypeM%(5):
  6589. act_on_fieldtype_menus(5)
  6590.  ftypeM%(6):
  6591. act_on_fieldtype_menus(6)
  6592.  ftypeM%(7):
  6593. act_on_fieldtype_menus(7)
  6594.  keystrokeM%:
  6595. act_on_keypad_menu
  6596.  valtablesM%:
  6597. act_on_menu_of_tables
  6598.  fieldsM%:
  6599. act_on_menu_of_fields
  6600.  indexesM%:
  6601. act_on_menu_of_indexes
  6602.  userM%:
  6603. act_on_user_menu
  6604.  mergecomM%:
  6605. tick_one(mergecomM%,0,2,choice1%):
  6606. set_mergecom_icons
  6607.  customise% 
  6608. (libfunc$+"_select(menuhandle%)")
  6609.  quit% 
  6610.  redo% 
  6611. show_menu(menuhandle%,menux%,menuy%)
  6612. display_font_name(S$)
  6613. S$,"\F")
  6614. S$,P%+2)
  6615. S$,"\")
  6616. S$,P%-1)
  6617. text(printerW%,fontdisplay%)=S$
  6618. redraw_icon(printerW%,fontdisplay%)
  6619. act_on_user_menu
  6620.  S%,menic%,flags%,wi%,ic%,L%,choice$
  6621. c0menic%=userM%+28+choice1%*24:flags%=menic%!8
  6622.  (flags% 
  6623.  (1<<8))=0 
  6624.   choice$=
  6625. $(menic%+12),12)
  6626.  choice$=$(menic%!12)
  6627. find_insertion_icon(menufield%)
  6628. insert_text(wi%,ic%,menufield%,choice$)
  6629. find_insertion_icon(F%)
  6630.  chartype%(F%) 
  6631.  64,65,66,67:
  6632.   S%=
  6633. scroller_number(F%)
  6634.  "Wimp_GetCaretPosition",,block%:wi%=!block%:ic%=block%!4
  6635.  wi%<>scrollerW%(S%) 
  6636.  wi%=scrollerW%(S%):ic%=0
  6637.   wi%=mainW%:ic%=field%(F%)
  6638. insert_text(wi%,ic%,F%,S$)
  6639.  fix%(F%)<>0 
  6640. fix_point(S$,F%)
  6641. buffer_length(wi%,ic%)
  6642. (S$)<=L% 
  6643. text(wi%,ic%)=S$
  6644. redraw_icon(wi%,ic%)
  6645. set_caret(0,wi%,ic%)
  6646.  wi%=mainW% 
  6647.  changed%=
  6648.  ScrollChanged%=
  6649. softerror(""""+S$+"""",7)
  6650. act_on_mark_menu
  6651.  choice$(1) 
  6652.  "Include":
  6653. tick(markM%,0,
  6654. tick(markM%,1,
  6655. val(markW%,0)="Snull,yes"
  6656.  "Exclude":
  6657. tick(markM%,1,
  6658. tick(markM%,0,
  6659. val(markW%,0)="Snull,no"
  6660. redraw_icon(markW%,0)
  6661. warn_of_marks
  6662. act_on_main_menu
  6663.  choice$(1) 
  6664.  "Information":
  6665. count(key%,RU%):
  6666. update_stats
  6667. position_window(miscW%,x%-200,y%-300,0,0,0,0)
  6668.  "Miscellaneous":
  6669. act_on_misc_menu
  6670.  "Print":
  6671. act_on_print_menu
  6672.  "Validation":
  6673. act_on_validation_menu
  6674.  "Index":
  6675. act_on_index_menu
  6676.  "Show keypad Tab":
  6677.  ShowTools% 
  6678. position_window(keypadW%,-1,-1,0,0,0,0)
  6679.  "Export subset":
  6680. ?  export%=
  6681. :$SubTitle%="Export subset":savefunc$=choice$(1)
  6682. +  $SubName%=
  6683. dir($database%)+".!Subset"
  6684. .  $SubSprite%="snew_appl;Pptr_hand,4,0;R2"
  6685. position_window(savesubW%,x%-244,y%-161,0,0,0,0):
  6686. set_caret(0,queryW%,0)
  6687.  "CSV files":
  6688. act_on_csv_menu
  6689.  "Undo changes":
  6690. restore(1,fields%,"",-1)
  6691.  "Help":
  6692.  "Wimp_StartTask","<Pbase$Dir>.!Help"
  6693. act_on_field_menu
  6694. act_on_index_menu
  6695.  choice$(2) 
  6696.  "Show details ^K":
  6697. show_key
  6698.  "Delete":
  6699. confirm(
  6700. msg("Err147,"+choice$(3))) 
  6701. remove_index(choice$(3),
  6702.  "Show files ^I":
  6703.  "OS_CLI","Filer_OpenDir "+$database%+".Indexes"
  6704. show_key
  6705. show_key
  6706. -$KeyTitle%=choice$(1):keyfunc$=choice$(1)
  6707. set_keydata(key%):
  6708. shade_key_icons(
  6709. position_window(keyW%,x%-284,y%-252,0,504,0,0)
  6710. act_on_csv_menu
  6711.  choice$(2) 
  6712.  "Export":
  6713. 9  $SubTitle%="Export CSV file":savefunc$="Export CSV"
  6714. C  $SubName%=$database%+".PrintJobs."+
  6715. set_up_save_box(2)+"file"
  6716. position_window(savesubW%,x%-244,y%-161,0,0,0,0):
  6717. set_caret(0,queryW%,0)
  6718.  "Options":
  6719.   $CSVTitle%="CSV options"
  6720. shade(csvW%,0,
  6721. text(csvW%,9)="Accept"
  6722. position_window(csvW%,x%-350,y%-180,700,440,0,0)
  6723. set_up_save_box(box%)
  6724.  f$,t$,v$
  6725. text(csvW%,14) 
  6726.  "Comma":f$="CSV"
  6727.  "TAB":f$="TSV"
  6728. :f$="?SV"
  6729. t$="dfe":Type%=&dfe
  6730. &v$="sfile_"+t$+";Pptr_hand,4,0;R2"
  6731.  box%=1 
  6732.  $SaveSprite%=v$ 
  6733.  $SubSprite%=v$
  6734. act_on_misc_menu
  6735.  choice$(2) 
  6736.  "Move/delete":
  6737. deselect(moveW%,
  6738. selected_esg(moveW%,1)):
  6739. select(moveW%,4)
  6740. shade(moveW%,8,
  6741. shade(moveW%,9,
  6742. shade(moveW%,12,
  6743. shade(moveW%,13,
  6744. '  source%=file%:dest%=(file%+1) 
  6745. text(moveW%,7)=$Subfile%(source%):$
  6746. text(moveW%,8)=$Subfile%(dest%):$
  6747. text(moveW%,1)="Move"
  6748. position_window(moveW%,x%-253,y%-232,0,0,0,0):
  6749. set_caret(0,queryW%,0)
  6750.  "Set passwords":
  6751. position_window(passW%,x%-213,y%-388,0,0,0,0):
  6752. set_caret(0,passW%,2)
  6753.  "Field colours":
  6754. position_window(colW%,x%-213,y%-388,0,0,0,0)
  6755.  "Edit template ^E":
  6756. check_record 
  6757.  template%=1:
  6758. display(key%,-1)
  6759.  "Name subfile":
  6760.  choice3% 
  6761. H    P%=
  6762. $RecInfo%,"Record")-1:$RecInfo%=$Subfilename%+
  6763. $RecInfo%,P%)
  6764. &    $Subfile%(file%)=$Subfilename%
  6765. asterisk(
  6766.  "Rename database":
  6767.  choice3%=0 
  6768. rename_database($NewName%)
  6769. act_on_print_menu
  6770.  choice$(2) 
  6771.  "Print","Create report":
  6772. match(x%-396,y%-131)
  6773.  "Show resources ^R":
  6774.  "OS_CLI","Filer_OpenDir "+$database%+".PrintRes"
  6775.  "Options":
  6776. select(printW%,32):
  6777. deselect(printW%,31)
  6778. position_window(printW%,x%-458,y%-401,0,0,0,0)
  6779. set_caret(0,printW%,26)
  6780.  "Save query":
  6781. -  $SaveName%=$database%+".PrintRes.Query"
  6782. 2  savefunc$=choice$(2):
  6783. save_click(saveW%,1,4)
  6784.  "Numeric fields":
  6785. position_window(pselectW%,0,0,0,0,0,0)
  6786.  "Extra calculations":
  6787. position_window(extracalcW%,0,0,0,0,0,0)
  6788. 2  calc%=Ecalc%:
  6789. set_up_calc(extracalcW%,calc%)
  6790.  "Save selection":
  6791. 1  $SaveName%=$database%+".PrintRes.Selection"
  6792. 2  savefunc$=choice$(2):
  6793. save_click(saveW%,1,4)
  6794.  "Show jobs done ^P":
  6795.  "OS_CLI","Filer_OpenDir "+$database%+".PrintJobs"
  6796.  "Clear selection ^Z":
  6797. clear_selection
  6798.  "Display selection":
  6799. get_calc(
  6800. (choice$(3)))
  6801.  "Select all ^A":
  6802. select_range(1,fields%,
  6803. act_on_validation_menu
  6804.  choice$(2) 
  6805.  "Create table":
  6806.  LastTable%=MaxTabs%-1 
  6807. 4    
  6808. softerror("tables,"+
  6809. (MaxTabs%)+",Tabs",23)
  6810.         
  6811. F    $
  6812. text(tabcreateW%,0)="":$
  6813. text(tabcreateW%,1)="":$tabcol%="0"
  6814.  I%=0 
  6815.  MaxCols%*2+1
  6816.        $
  6817. text(scrollW%,I%)=""
  6818.     *    
  6819. set_icon_cols(tabcreateW%,13,&28)
  6820. *    
  6821. set_icon_cols(tabcreateW%,14,&07)
  6822. W    
  6823. position_window(tabcreateW%,x%-241,y%-301,0,0,0,0):
  6824. set_caret(0,tabcreateW%,0)
  6825.  "Display table":
  6826.  choice3%>=0 
  6827.     Tablenumber%=choice3%
  6828. %    
  6829. show_table(Tablenumber%,0,0)
  6830.  "Show files ^Q":
  6831.  "OS_CLI","Filer_OpenDir "+$database%+".ValTables"
  6832. act_on_field_menu
  6833. choice$(2),1)="."
  6834.   choice$(2)=
  6835. choice$(2),2)
  6836.  choice$(2) 
  6837.  "Create index":
  6838. =  keyfunc$=choice$(2):$KeyTitle%=keyfunc$+": "+Fieldname$
  6839. shade_key_icons(
  6840. deselect(keyW%,30):
  6841. deselect(keyW%,35):
  6842. deselect(keyW%,37)
  6843. position_window(keyW%,x%-284,y%-252,0,504,0,0):
  6844. set_caret(0,keyW%,13)
  6845.  "Analyse index":
  6846. analyse(
  6847. is_a_key(Fieldnumber%))
  6848.  "Analyse months":
  6849. analyse(-1)
  6850.  "Link to table":
  6851. position_window(linkW%,x%-350,y%-129,0,0,0,0)
  6852.  "Calculations","Combine fields","Set base value":
  6853. position_window(calcW%,0,0,0,0,0,0):
  6854. set_caret(0,calcW%,0)
  6855.  "Global changes":
  6856. position_window(changeW%,x%-252,y%-214,0,0,0,0):
  6857. set_caret(0,changeW%,0)
  6858.  "Start editing ^S":
  6859. &]  starthere%=field%(Fieldnumber%):$StartHere%=Tag$(Fieldnumber%):
  6860. redraw_icon(prefsW%,45)
  6861.  Access% 
  6862. set_caret(0,mainW%,starthere%)
  6863.  "Remove text file","Remove sprite","Remove drawfile","Unlink directory","Unlink file","Blank list":
  6864.  chartype%(Fieldnumber%) 
  6865. +4    link$(Fieldnumber%)="":$Rf%(Fieldnumber%)=""
  6866. ,:    $
  6867. val(mainW%,field%(Fieldnumber%))="R5;Ssmall_dir"
  6868. -1    
  6869. redraw_icon(mainW%,field%(Fieldnumber%))
  6870. /4    link$(Fieldnumber%)="":$Rf%(Fieldnumber%)=""
  6871. 07    $
  6872. val(mainW%,field%(Fieldnumber%))="R5;Saction"
  6873. 11    
  6874. redraw_icon(mainW%,field%(Fieldnumber%))
  6875. 2"    
  6876.  60:$Rf%(Fieldnumber%)=""
  6877. 3F    $
  6878. val(mainW%,field%(Fieldnumber%))="R5;Pptr_ext,8,4;Sdropfile"
  6879. 41    
  6880. redraw_icon(mainW%,field%(Fieldnumber%))
  6881. 5H    
  6882. delete_blob(Fieldnumber%,object$,mainW%,field%(Fieldnumber%))
  6883. asterisk(
  6884.  "Save text file":
  6885. 9I  $SaveName%=$database%+".PrintJobs.TextFile":
  6886. save_click(saveW%,1,4)
  6887.  "Save sprite":
  6888. ;G  $SaveName%=$database%+".PrintJobs.Sprite":
  6889. save_click(saveW%,1,4)
  6890.  "Save drawfile":
  6891. =I  $SaveName%=$database%+".PrintJobs.DrawFile":
  6892. save_click(saveW%,1,4)
  6893.  "Save as list":
  6894. ?1  $SaveName%=$database%+".PrintJobs.TextList"
  6895. @2  savefunc$=choice$(2):
  6896. save_click(saveW%,1,4)
  6897.  "Save as CSV":
  6898. BE  $SaveName%=$database%+".PrintJobs."+
  6899. set_up_save_box(1)+"file":
  6900. CC  savefunc$=choice$(2):writescroller%=
  6901. save_click(saveW%,1,4)
  6902.  "Undo changes":
  6903. restore(Fieldnumber%,Fieldnumber%,"",-1)
  6904.  "Compact sequence":
  6905. compact(Fieldnumber%)
  6906. compact(F%)
  6907.  sequenceval$,V$
  6908. is_a_key(F%) 
  6909.  key%:
  6910. confirm(
  6911. msg("Err128")) 
  6912. N'    
  6913. split_link(F%,V$,sequenceval$)
  6914.     V$=sequenceval$
  6915.  "Hourglass_On"
  6916. Q.    dbasehandle%=
  6917. ($database%+".Database")
  6918. R!    P%=
  6919. neighbour(key%,top,1)
  6920. S,    
  6921. scan_file("P%<>top",key%,file%,7,1)
  6922.  "Hourglass_Off"
  6923. U!    
  6924. close_file(dbasehandle%)
  6925. V%    calc$(F%)=V$+"|"+sequenceval$
  6926. save_calcs:
  6927. save_keys
  6928. softerror(Tag$(F%),116)
  6929. softerror(Tag$(F%),127)
  6930. act_on_keypad_menu
  6931.  choice$(1) 
  6932.  "Defaults":
  6933. load_functionkeys
  6934.  "Save choices":
  6935. save_fkeys
  6936.  "List keys":
  6937. list_fkeys
  6938. act_on_csv_sep
  6939.  choice$(1) 
  6940.  "Comma":sep$=","
  6941.  "TAB":sep$=
  6942.  "CR":sep$=
  6943.  "LF":sep$=
  6944.  sep$=$Delim%
  6945. tick_one(menuhandle%,0,3,choice1%)
  6946. text(csvW%,14)=choice$(1)
  6947. redraw_icon(csvW%,14)
  6948. act_on_csv_term
  6949.  choice$(1) 
  6950.  "CR":term$=
  6951. (13)                               
  6952.  "LF":term$=
  6953.  "CR LF":term$=
  6954. (13)+
  6955.  "LF CR":term$=
  6956. (10)+
  6957.  "CR CR":term$=
  6958. (13)+
  6959.  "LF LF":term$=
  6960. (10)+
  6961. :term$=$Termin%
  6962. tick_one(menuhandle%,0,5,choice1%)
  6963. text(csvW%,15)=choice$(1)
  6964. redraw_icon(csvW%,15)
  6965. act_on_csv_scrollterm
  6966.  choice$(1) 
  6967.  "Semicolon":scrollterm$=";"
  6968.  "Comma":scrollterm$=","
  6969.  "TAB":scrollterm$=
  6970.  "Space":scrollterm$=" "
  6971. :scrollterm$=$Scrterm%
  6972. tick_one(menuhandle%,0,3,choice1%)
  6973. text(csvW%,27)=choice$(1)
  6974. redraw_icon(csvW%,27)
  6975. act_on_text_menu
  6976. choice$(1),4) 
  6977.  "Save":
  6978.   $SaveName%=TextName$
  6979. /  $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  6980. 2  savefunc$=choice$(1):
  6981. save_click(saveW%,1,4)
  6982.  "Sort":
  6983.  choice2%=1 
  6984.  z%=-1 
  6985.  z%=1
  6986. sort_list(sort_textcol%,z%)
  6987.  "Shri":
  6988. remove_white_space(format$)
  6989. screen_list
  6990.  "Disc":
  6991. lose_list
  6992. act_on_create_menu
  6993.  choice$(1) 
  6994.  "Create field":
  6995. selected_esg(createW%,1)=54 
  6996. %    wht%=730:
  6997. sformat(createW%,
  6998. "    
  6999. set_scroll_def(0,1,
  7000. '    
  7001.  wht%=640:
  7002. sformat(createW%,
  7003. "    
  7004. set_scroll_def(0,0,
  7005. position_window(createW%,x%-425,y%-320,0,wht%,0,0):
  7006. set_caret(0,createW%,4)
  7007.  "Edit field":
  7008.  vtype$(chartype%(Fieldnumber%))="L" 
  7009.  wht%=730 
  7010.  wht%=640
  7011. position_window(createW%,x%-425,y%-320,0,wht%,0,0):
  7012. set_caret(0,createW%,4)
  7013.  "Fields created":
  7014.  choice2%>=0 
  7015. design_field(2,choice2%*2+1,
  7016.  "Save form file":
  7017. #  $SaveName%=$database%+".Form"
  7018. 2  savefunc$=choice$(1):
  7019. save_click(saveW%,1,4)
  7020.  "Default database":
  7021. save_form($database%+".Form")
  7022. first_writable>0 
  7023. default_key
  7024. #    
  7025. defaults($database%,100,0)
  7026. softerror("",35)
  7027.  "Primary key":
  7028. $  fieldsM%=
  7029. field_menu(items%,1)
  7030.   F%=
  7031. first_writable
  7032. 0  starthere%=field%(F%):$StartHere%=Tag$(F%)
  7033.   $KeyTitle%=choice$(1)
  7034.   keyfunc$=choice$(1)
  7035.    case%(0)=
  7036. set_keydata(0)
  7037. shade_key_icons(
  7038. shade(keyW%,37,
  7039. position_window(keyW%,x%-284,y%-252,0,504,0,0):
  7040. set_caret(0,keyW%,13)
  7041.  "Quit design":
  7042. quit_design
  7043. quit_design
  7044.  F%,real$,visible$
  7045. nosave%=
  7046. adjust_on(
  7047. save_form($database%+".Form")
  7048. save_calcs
  7049.  $Reformatted%<>"" 
  7050. close_window(mainW%)
  7051. complete(6)
  7052. get_it_in($Original%)
  7053. complete(6)
  7054. do_reformat
  7055. get_it_in($database%):
  7056. do_reformat
  7057.  $Reformatted%=$database% 
  7058. softerror("",36):
  7059. reformat($Reformatted%) 
  7060. softerror($Reformatted%+",",178):
  7061. close_window(reformW%)
  7062. &db$=$Reformatted%:$Reformatted%=""
  7063. get_it_in(db$)
  7064. complete(6)
  7065. selected(reformW%,11) 
  7066. softerror($database%+","+$Original%,161)
  7067.  F%,I%,R$,V$,old$,new$
  7068.  F%=1 
  7069.  fields%
  7070.  chartype%(F%) 
  7071.  6,7:
  7072. split_link(F%,R$,V$)
  7073. '    
  7074. calc_formula(F%,calcW%,1,4,V$)
  7075.  menfield%(I%,0)<>-1
  7076. =  buttonfield%=menfield%(I%,0):datafield%=menfield%(I%,1)
  7077.  Tag$(buttonfield%)<>Tag$(datafield%) 
  7078. 4    
  7079.  Datafield for menu must have a renamed tag
  7080. C    old$=Tag$(buttonfield%)+"menu":new$=Tag$(datafield%)+"menu"
  7081. U    
  7082.  "OS_CLI","Rename "+$database%+".Menus."+old$+" "+$database%+".Menus."+new$
  7083. +    Tag$(buttonfield%)=Tag$(datafield%)
  7084.   I%+=1
  7085. save_form($database%+".Form")
  7086. store_menu_inf
  7087.  F%,I%,datafield%
  7088. menfield%()=-1
  7089.  F%=1 
  7090.  fields%
  7091.  chartype%(F%)=33 
  7092.     datafield%=0
  7093.         
  7094.       datafield%+=1
  7095. #    
  7096.  Tag$(datafield%)=Tag$(F%)
  7097. 5    menfield%(I%,0)=F%:menfield%(I%,1)=datafield%
  7098.     I%+=1
  7099. act_on_fieldtype_menus(m%)
  7100. currenttype%=choice1%
  7101. +fieldtype%=?(flist%(m%)+currenttype%+1)
  7102. tick_one(menuhandle%,0,lasttype%,choice1%)
  7103. update_box
  7104.  fieldtype% 
  7105.  64,65,66,67:
  7106. set_scroll_def(0,fieldtype%-63,
  7107. set_scroll_def(0,0,
  7108. act_on_menu_of_tables
  7109. Tablenumber%=choice1%
  7110. $$Tablename%=table$(Tablenumber%)
  7111. tick_one(menuhandle%,0,LastTable%,choice1%)
  7112. redraw_icon(linkW%,0)
  7113. act_on_menu_of_fields
  7114. (choice$(1)):
  7115.  Items start with field-number
  7116.  fieldfunc$ 
  7117.  "mergecom":mergefield%=F%:
  7118. set_mergecom_icons
  7119.  "getcalc":
  7120. get_calc(F%)
  7121.  "calc":
  7122. enter_tag(Tag$(F%))
  7123.  "create":
  7124. design_field(2,F%*2-1,
  7125.  "help":
  7126.   Match_tag%=F%
  7127.  >  $
  7128. text(helpW%,0)=Tag$(Match_tag%):
  7129. redraw_icon(helpW%,0)
  7130. tick_one(menuhandle%,0,items%,choice1%)
  7131.  "CtrlF":
  7132.  printorder$="" 
  7133.   Fieldnumber%=F%
  7134. %A    
  7135.  chartype%(Fieldnumber%)<6 
  7136.  chartype%(Fieldnumber%)=8 
  7137. &3      
  7138. set_caret(0,mainW%,field%(Fieldnumber%))
  7139. '.      
  7140. selected(prefsW%,19) 
  7141. relations
  7142. (        
  7143. get_calc(F%)
  7144.  "0","1","2","3":
  7145.   keyfield%=
  7146. (fieldfunc$)
  7147.  keyfunc$<>"Current key" 
  7148. ."    
  7149. ticked(fieldsM%,F%-1) 
  7150. /O      keyfield%(keyfield%)=0:
  7151. kcycle(keyfield%(keyfield%),4*keyfield%+12,0)
  7152.       
  7153. 1P      keyfield%(keyfield%)=F%:
  7154. kcycle(keyfield%(keyfield%),4*keyfield%+12,0)
  7155. 22      
  7156. tick_one(menuhandle%,0,items%,choice1%)
  7157. 3        
  7158. get_calc(F%)
  7159.  F%>MaxFields%+2 
  7160.   calc%=F%-MaxFields%-3
  7161. position_window(extracalcW%,0,0,0,0,0,0)
  7162. set_up_calc(extracalcW%,calc%)
  7163. act_on_table_menu(ch$)
  7164.  ch$="Save":
  7165. C2  $SaveName%=$database%+".ValTables."+$tableM%
  7166. D4  savefunc$="Save table":
  7167. save_click(saveW%,1,4)
  7168.  ch$="Save as CSV":
  7169. FF  $SaveName%=$database%+".PrintJobs."+
  7170. set_up_save_box(1)+$tableM%
  7171. G9  savefunc$=ch$:writetable%=
  7172. save_click(saveW%,1,4)
  7173.  ch$="Clear":
  7174. clear_table(Tablenumber%)
  7175.  ch$="Print":
  7176. print_table(Tablenumber%)
  7177. ch$,4)="Sort":
  7178. sort_table(Tablenumber%,sort_tabcol%)
  7179.  ch$="Undo all":
  7180. restore_table(Tablenumber%)
  7181.  ch$="Undo change":
  7182. restore_tabfield
  7183.  ch$="Modify":
  7184. modify_table(Tablenumber%,tabcreateW%)
  7185. act_on_icon_bar_menu
  7186.  choice$(1) 
  7187.  "Rename database":
  7188.  choice2%=0 
  7189. rename_database($NewName%)
  7190.  "Help":
  7191.  "Wimp_StartTask","<Pbase$Dir>.!Help"
  7192.  "Utilities":
  7193.  choice$(2) 
  7194.  "New primary key":
  7195.     $KeyTitle%=choice$(2)
  7196. Y+    keyfunc$=choice$(2):
  7197. set_keydata(0)
  7198.  (present% 
  7199.  2)=2 
  7200. [/      
  7201. select(keyW%,32):
  7202. deselect(keyW%,33)
  7203. \/      
  7204. shade(keyW%,32,
  7205. shade(keyW%,33,
  7206.       
  7207. ^/      
  7208. select(keyW%,33):
  7209. deselect(keyW%,32)
  7210. _/      
  7211. shade(keyW%,32,
  7212. shade(keyW%,33,
  7213. `        
  7214. a.    
  7215. shade_key_icons(
  7216. shade(keyW%,37,
  7217. bN    
  7218. position_window(keyW%,x%-284,y%-303,0,606,0,0):
  7219. set_caret(0,keyW%,13)
  7220. c1    
  7221.  "New record format","Rebuild database":
  7222. d1    
  7223. shade(reformW%,0,
  7224. shade(reformW%,2,
  7225. eE    $Original%=$database%:$Reformatted%="!NewFormat":$Newform%=""
  7226. f5    
  7227. position_window(reformW%,x%-237,100,0,0,0,0)
  7228. g     
  7229. set_caret(0,reformW%,6)
  7230. h)    
  7231.  "Adjust format","Alter format":
  7232. check_record 
  7233.       
  7234. adjust_on(
  7235.       
  7236. store_menu_inf
  7237.       
  7238. open_window(mainW%)
  7239.       
  7240. display(key%,-1)
  7241. n        
  7242.  "Merge databases":
  7243. pI    $
  7244. text(mergebaseW%,2)=$database%:$
  7245. text(mergebaseW%,4)=$database%
  7246. qO    
  7247. shade(mergebaseW%,4,
  7248. shade(mergebaseW%,7,
  7249. shade(mergebaseW%,1,
  7250. r     $
  7251. text(mergebaseW%,3)=""
  7252. s8    
  7253. position_window(mergebaseW%,x%-237,100,0,0,0,0)
  7254. t]    
  7255.  "Balance index ^B":
  7256. balance(key%):
  7257. print_tree(key%,"TOTALS"):
  7258. rectify_address(key%)
  7259. u1    S$=key$(key%):
  7260.  case%(key%) 
  7261. u(S$)
  7262. vA    val$=
  7263. type(key%):
  7264.  val$="VAL" 
  7265.  kl%=KL%(key%) 
  7266.  kl%=
  7267. w#    addr=
  7268. search(S$,key%,2)    
  7269.  "Print index":
  7270.  choice$(3) 
  7271. z7      
  7272.  "All subfiles":
  7273. tick_one(indextreeM%,0,1,0)
  7274. {:      
  7275.  "Current subfile":
  7276. tick_one(indextreeM%,0,1,1)
  7277. |6      
  7278.  "Symmetrical":
  7279. tick_one(indextreeM%,2,3,2)
  7280. }5      
  7281.  "Root first":
  7282. tick_one(indextreeM%,2,3,3)
  7283.       
  7284.  "Complete":
  7285. !      
  7286. print_tree(key%,"ALL")
  7287.       
  7288.  "Totals only":
  7289. $      
  7290. print_tree(key%,"TOTALS")
  7291. &      
  7292. print_tree(key%,"TOTALS")
  7293.         
  7294. (    
  7295.  "Print field data":
  7296. field_data
  7297. -    
  7298.  "Find duplicates":
  7299. duplicates(key%)
  7300.  "Merge commands":
  7301. <    mergefield%=1:$
  7302. text(mergecomW%,3)=Tag$(mergefield%)
  7303. 0    
  7304. tick_one(mergecomM%,0,2,0):$Expcol%="1"
  7305. set_mergecom_icons
  7306. 0    
  7307. position_window(mergecomW%,0,0,0,0,0,0)
  7308.  "Close database":
  7309. check_record 
  7310.  $Reformatted%="":
  7311.  Setting reformat name to "" cannot be done inside PROCexit because it is called during reformatting process where pathname must be remembered
  7312.  "Preferences":
  7313. position_window(prefsW%,x%-371,150,0,0,0,0):
  7314. set_caret(0,prefsW%,1)
  7315.  "Quit":
  7316.  Access% 
  7317.  quit%=
  7318. check_record 
  7319.  quit%=
  7320. reveal(vis%)
  7321.  F%,dic%,fic%
  7322.  Modify% 
  7323.  F%=1 
  7324.  fields%
  7325. &    dic%=desc%(F%):fic%=field%(F%)
  7326.  hide%?F%=1 
  7327.       
  7328.  vis% 
  7329.         
  7330.         K%=
  7331. is_a_key(F%)
  7332.         
  7333.  K%=-1 
  7334. P          
  7335. set_icon_cols(wi%,dic%,winback%*16+7):
  7336. set_icon_cols(wi%,fic%,04)
  7337. 9          
  7338. colour(K%,2):
  7339. set_icon_cols(wi%,fic%,04)
  7340.         
  7341. Y        
  7342. set_icon_cols(wi%,dic%,winback%*17):
  7343. set_icon_cols(wi%,fic%,winback%*17)
  7344.       
  7345.         
  7346. make_index_menu
  7347. protect(wi%,ic%,F%)
  7348.  Modify% 
  7349. get_icon_cols(wi%,ic%) 
  7350. 2    
  7351. set_icon_cols(wi%,ic%,04):hide%?F%=1
  7352. 2    
  7353. set_icon_cols(wi%,ic%,07):hide%?F%=0
  7354.   protect%=
  7355. init_drag(wi%,ic%,dragtype%)
  7356. !block%=wi%
  7357.  "Wimp_GetWindowState",,block%
  7358. x%=block%!4-block%!20
  7359. y%=block%!16-block%!24
  7360. block%!4=ic%
  7361.  "Wimp_GetIconState",,block%
  7362. block%!8+=x%:minx%=block%!8
  7363. !block%!12+=y%:miny%=block%!12
  7364. !block%!16+=x%:maxx%=block%!16
  7365. !block%!20+=y%:maxy%=block%!20
  7366.  dragtype%=6 
  7367. 5  block%!24=2*minx%-maxx%:block%!36=2*maxy%-miny%
  7368.  block%!24=0:block%!36=ScreenHeight%
  7369. Cblock%!28=0:block%!32=ScreenWidth%:!block%=0:block%!4=dragtype%
  7370.  wi% 
  7371.  mainW%,scrollerW%(Scroller%):
  7372.  dragtype% 
  7373.  design% 
  7374. .      ficon%=ic%:
  7375.  "Wimp_DragBox",,block%
  7376.       
  7377. D      sprite$="file_fff":Filename$=Tag$(Fieldnumber%):Type%=&fff
  7378. A      Start%=
  7379. text(wi%,ic%):End%=Start%+
  7380. text_length(wi%,ic%)
  7381. C      
  7382.  "Wimp_GetPointerInfo",,block%:x1%=!block%:y1%=block%!4
  7383. A      !block%=wi%:block%!4=ic%:
  7384.  "Wimp_GetIconState",,block%
  7385. @      block%!8=x1%:block%!12+=y%:block%!16=x1%:block%!20+=y%
  7386. P      block%!24=0:block%!36=ScreenHeight%:block%!28=0:block%!32=ScreenWidth%
  7387. 7      
  7388.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7389.         
  7390. <    
  7391.  design% 
  7392.  ficon%=ic%:
  7393.  "Wimp_DragBox",,block%
  7394.  mergecomW%:
  7395.  "DragASprite_Start",&C5,1,"file_fff",block%+8  
  7396.  saveW%:
  7397. !  sprite$=
  7398. $SaveSprite%,2,8) 
  7399.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7400.  savesubW%:
  7401.   sprite$=
  7402. $SubSprite%,2,8)
  7403.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7404.  mergebaseW%:
  7405. !  sprite$=
  7406. $MergeSprite%,2,8)
  7407.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7408.  reformW%:
  7409.  "DragASprite_Start",&C5,1,"new_appl",block%+8
  7410.  passW%:
  7411.   sprite$=
  7412. $LogSprite%,2,9)
  7413.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7414.  aclW%:
  7415.   sprite$=
  7416. $AclSprite%,2,8)
  7417.  "DragASprite_Start",&C5,1,sprite$,block%+8
  7418.  "Wimp_DragBox",,block%
  7419. end_drag
  7420.  See PRM 3-197,3-143,3-252
  7421.  "Wimp_GetPointerInfo",,block%
  7422. 3block%!20=block%!12:
  7423.  Destination window handle
  7424. 1block%!24=block%!16:
  7425.  Destination icon handle
  7426. Hblock%!28=block%!0:block%!32=block%!4:
  7427.  x,y co-ords where drag ended
  7428. 8block%!16=1:
  7429.  Send DataSave message to external app.
  7430. 9block%!12=0:
  7431.  Your ref (0, since this is not a reply)
  7432. datasize%=End%-Start%
  7433. 'block%!36=datasize%:block%!40=Type%
  7434.  design% 
  7435.  dragbutt%>0 
  7436. adjust_field(dragbutt%)
  7437.  Filename$<>"" 
  7438. %    $(block%+44)=
  7439. leaf(Filename$)
  7440. ,    !block%=64:
  7441.  Length of message block
  7442. ;    
  7443.  "Wimp_SendMessage",18,block%,block%!20,block%!24
  7444.     ramptr%=Start%
  7445.      
  7446.  "Wimp_CreateMenu",,-1
  7447. encrypt(S$,Z%)
  7448.  I%,R%
  7449. (-12817)
  7450.  I%=1 
  7451. S$,I%,1)>"@" 
  7452.     R%=
  7453. (58)-1
  7454.  R%=58-R%
  7455. 1    
  7456. S$,I%,1)=
  7457. S$,I%,1))-65+R%) 
  7458.  58+65)
  7459. dir(s$)
  7460.  leaf$
  7461. leaf$=
  7462. leaf(s$)
  7463. =leafnamepath$
  7464. leaf(s$)
  7465. s2$=""
  7466. s$)<>"." 
  7467.  s$<>""
  7468.   s2$=
  7469. s$)+s2$
  7470.   s$=
  7471. leafnamepath$=
  7472.  Message handling ----------------------------------------------------
  7473. not_acknowledged
  7474.  block%!16 
  7475.  RAMTransmit failed
  7476.  merging% 
  7477.  moan_err%,
  7478. msg("Err39")
  7479.  DataLoad sent by Powerbase but unacknowledged, hence returned
  7480.  At this point, the message ought to have been sent by us, so check it
  7481.  Very bizarre situation if you get this error (!!)
  7482.  block%!8<>my_ref% 
  7483.  moan_err%,"Reference fields mismatch (msglost/DataLoad)"
  7484.  If transfer marked as temporary, delete scrap file
  7485.  block%!36=-1 
  7486.  "OS_File",6,block%+44
  7487.  moan_err%,
  7488. msg("Err39")
  7489.  &80142:
  7490.  moan_err%,
  7491. msg("Err90")
  7492.  ### Attempt to print directly when no driver installed ###
  7493.  &4AF80:
  7494.  block%!8=my_ref% 
  7495.  "Wimp_StartTask",Run_It$
  7496.  ### No browser loaded to fetch URL ###
  7497. message
  7498.  task%,task$,filename$,wi%,ic%
  7499. 2Atask%=block%!4:your_ref%=block%!8:wi%=block%!20:ic%=block%!24
  7500.  block%!16 
  7501.  Access% 
  7502.  quit%=
  7503. check_record 
  7504.  quit%=
  7505.  DataSave - request by external task to save to Powerbase
  7506.  or to 'save' one Powerbase field into another in same database
  7507.  (dragfield%>0 
  7508.  task%<>mytask%) 
  7509.  present%=7 
  7510.     datasize%=block%!36
  7511.  block%!40 
  7512. :       
  7513.  &fff,&ff9,&aff,&dfe:
  7514. ;C      block%!0=256:block%!12=your_ref%:block%!16=2:block%!36=-1
  7515. <*      $(block%+44)="<Wimp$Scrap>"+
  7516. =B      
  7517.  "Wimp_SendMessage",17,block%,task%:
  7518.  Send DataSaveAck
  7519. >        
  7520.  DataSaveAck - Powerbase wishes to save to external app.
  7521.  DataSave has been sent & acknowledgement now received
  7522. B2  Type%=block%!40:filename$=
  7523. getstr(block%+44)
  7524.  filename$<>"" 
  7525. E$      
  7526.  savefunc$="Save object":
  7527. FU      
  7528.  "OS_CLI","Copy "+$database%+"."+$Rf%(Fieldnumber%)+" "+filename$+" ~C~V"
  7529. GO      
  7530.  reformat%>0 
  7531.  filename$=$database%:
  7532. softerror(
  7533. leaf(filename$),200)
  7534.       
  7535. I"      
  7536.  dragfield%>0 
  7537. (-1) 
  7538. JM        $savebuff%="{merge "":Powerbase GetField "+Tag$(dragfield%)+"""}"
  7539. KA        Start%=savebuff%:End%=Start%+
  7540. ($savebuff%):Type%=&fff
  7541.         dragfield%=0
  7542.       
  7543. N,      
  7544. save(filename$,Type%,Start%,End%)
  7545. OL      
  7546. leaf(filename$)<>"Log" 
  7547. write_log(-1,"File saved:",filename$)
  7548. P2      block%!0=256:block%!20=wi%:block%!24=ic%
  7549. Q9      block%!12=your_ref%:block%!16=3:
  7550.  Send DataLoad
  7551. R2      
  7552.  "OS_File",5,filename$ 
  7553.  ,,,,block%!36
  7554. S5      block%!40=Type%:$(block%+44)=filename$+
  7555. T/      
  7556.  "Wimp_SendMessage",18,block%,task%
  7557.       my_ref%=block%!8
  7558. V        
  7559.  "Wimp_CreateMenu",,-1
  7560.  DataLoad - request from external app. for Powerbase to load file
  7561. Z+  f$=
  7562. getstr(block%+44):type%=block%!40
  7563.  "TaskManager_TaskNameFromHandle",task% 
  7564.  task$
  7565. ]@    
  7566.  task$=progname$ 
  7567.  type%=&fff:
  7568. load_to_icon(f$,wi%,ic%)
  7569. ^M    
  7570.  One data field dragged to another, not necessarily in same database
  7571. _&    
  7572.  pasting%:
  7573. from_clipboard(f$)
  7574. get_it_in(f$)
  7575.  block%!8<>0 
  7576.  "OS_CLI","Remove <Wimp$Scrap>"
  7577. c>  !block%=20:block%!12=your_ref%:block%!16=4:
  7578.  Acknowledge
  7579.  "Wimp_SendMessage",17,block%,task%
  7580.  DataLoadAck - external app. acknowledges data sent by Powerbase
  7581.  ### DataOpen - response to file double click ###
  7582.  block%!40 
  7583.  &7f1,&7f3,&7f4,&7f5:
  7584.  present%=7 
  7585. j4      !block%=20:block%!12=your_ref%:block%!16=4
  7586. k/      
  7587.  "Wimp_SendMessage",17,block%,task%
  7588.       block%!20=-1
  7589. m(      
  7590. get_it_in(
  7591. getstr(block%+44))
  7592. n        
  7593.  &2000:
  7594.  kill% 
  7595.  present%=0 
  7596. q2      
  7597.  ### Is it a Powerbase application? ###
  7598.       f$=
  7599. getstr(block%+44)
  7600. s2      
  7601.  "OS_File",5,f$+".Indices" 
  7602.  d%,,type%
  7603. tE      
  7604.  d%=2 
  7605.  "OS_CLI","Rename "+f$+".Indices "+f$+".Indexes"
  7606. u8      
  7607.  "OS_File",5,f$+".Indexes" 
  7608.  d%,,type%      
  7609. v!      type%=(type%>>8) 
  7610.  &fff
  7611.       
  7612.  d%=2 
  7613. x6        !block%=20:block%!12=your_ref%:block%!16=4
  7614. y1        
  7615.  "Wimp_SendMessage",17,block%,task%
  7616. z*        
  7617. get_it_in(
  7618. getstr(block%+44))
  7619.       
  7620. |        
  7621.  RAMFetch - Ignore this message if not a simple memory-block save
  7622.  savefunc$ 
  7623.  "Save as text","Save text","Save sprite","Save draw","Save query","Save selection","Save table","Export selected","Clipboard":
  7624. ram_transmit
  7625.  ### Desktop boot file ###
  7626.  "OS_GSTrans","Run <PBase$Dir>",block%+&100,&f00 
  7627.  ,bootcmd$
  7628. #block%!20,bootcmd$
  7629.  ### Claim entity; an app has claimed input focus or clipboard ###
  7630.  (block%!20) 
  7631.  %100 
  7632.  clip%=
  7633.  ### Data request; an application wants to paste from clipboard ###
  7634.  (block%!36) 
  7635.  %100 
  7636. c    block%!12=your_ref%:block%!36=
  7637. (scratchpad$)+1:block%!40=&fff:$(block%+44)="Clipboard"+
  7638. 9    block%!16=1:
  7639.  "Wimp_SendMessage",18,block%,task%
  7640.     my_ref%=block%!8
  7641.  &502:
  7642. help_message(task%,your_ref%,block%!32,block%!36)
  7643.  &400C0:
  7644. message_menu_select
  7645.  &400C1:
  7646.  ### Mode change ###
  7647. getscreensize(ScreenWidth%,ScreenHeight%,Vpix%)
  7648. load_sprites
  7649.  &400CC:
  7650.  block%!20=mainW% 
  7651.  iconise%=
  7652.  &400CF:
  7653.  ### Desktop font changed ###
  7654.  Desktopfont%>0 
  7655.  Desktopfont%<>block%!20 
  7656.  Desktopfont%=block%!20:
  7657. softerror("",146)
  7658. ram_transmit
  7659.  datasize%>block%!24 
  7660.  tosend%=block%!24 
  7661.  tosend%=datasize%
  7662.  "Wimp_TransferBlock",mytask%,ramptr%,block%!4,block%!20,tosend%
  7663. block%!24=tosend%
  7664. datasize%-=tosend%
  7665. ramptr%+=tosend%
  7666. #block%!12=your_ref%:block%!16=7
  7667.  "Wimp_SendMessage",18+(datasize%=0),block%,block%!4
  7668. my_ref%=block%!8
  7669. load_to_icon(f$,wi%,ic%)
  7670.  L%,F,len%,F%,ok%,V%,b$,butt%,I%
  7671.  ic%<0 
  7672. dragfield%=0
  7673. buffer_length(wi%,ic%)
  7674.  "OS_File",5,f$ 
  7675.  ,,,,len%
  7676.  len%>255 
  7677.  wi%=mainW% 
  7678. )  F%=
  7679. get_field(ic%):V%=chartype%(F%)
  7680.  ic% 
  7681.  2=0:ok%=0
  7682.  V%=36 
  7683.  V%=39:
  7684. 1    L%=
  7685. blob_path(
  7686. ,$database%,REC%,F%,36,b$)
  7687. -    
  7688.  "OS_CLI","Copy "+f$+" "+b$+" ~C~V"
  7689.     ok%=2
  7690. A    
  7691.  V%=39 
  7692. show_text_block(F%,REC%):
  7693. redraw_icon(wi%,ic%)
  7694.  vtype$(V%)="E":ok%=1
  7695. /    
  7696.  vtype$(V%)="L":ok%=1:ScrollChanged%=
  7697. =  !block%=wi%:block%!4=ic%:
  7698.  "Wimp_GetIconState",,block%
  7699. $  butt%=((block%!25)>>4) 
  7700.  %1111
  7701.  butt%=14 
  7702.  butt%=15 
  7703.  ok%=1
  7704.  I%=0 
  7705.  Scrollnum%-1
  7706. $    
  7707.  wi%=scrollerW%(I%) 
  7708.  ok%=3
  7709.  I%  
  7710.  ok% 
  7711. softerror("",213)
  7712.  1,3:
  7713.  "OS_File",255,f$,savebuff%
  7714.   savebuff%?len%=13
  7715. text(wi%,ic%)=
  7716. $savebuff%,L%)
  7717. set_caret(0,wi%,ic%)
  7718. redraw_icon(wi%,ic%)
  7719.  ok%=3 
  7720.  ScrollChanged%=
  7721. message_menu_select
  7722.  P%,Q%,I%
  7723. keyfunc$=""
  7724. 5handle%=block%!20:xmin%=block%!24:ymax%=block%!28
  7725.  "Wimp_DecodeMenu",,menuhandle%,block%+32,choices%
  7726. text(saveW%,4)="":
  7727. shade(saveW%,4,
  7728. deselect(saveW%,4)
  7729.  I%=1 
  7730.   Q%=
  7731. $choices%,".",P%+1)
  7732. &  choice$(I%)=
  7733. $choices%,P%,Q%-P%)
  7734.   P%=Q%+1
  7735.  menuhandle% 
  7736.  iconbarM%:
  7737.  choice$(1) 
  7738.  "New database":
  7739.     $SaveName%="!DataBase"
  7740. 1    $SaveSprite%="snew_appl;Pptr_hand,4,0;R2"
  7741.     savefunc$=choice$(1)
  7742.  mainM%:
  7743.  choice$(2) 
  7744.  "Save as list":
  7745. 3    $SaveName%=$database%+".PrintJobs.TextList"
  7746. 1    $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  7747.     savefunc$=choice$(2)
  7748.  "Save as CSV":
  7749. F    $SaveName%=$database%+".PrintJobs."+
  7750. set_up_save_box(1)+"file"
  7751. -    savefunc$=choice$(2):writescroller%=
  7752.  choice$(1) 
  7753.  "Print":
  7754.  choice$(2) 
  7755.       
  7756.  "Save query":
  7757. 1      $SaveName%=$database%+".PrintRes.Query"
  7758. 3      $SaveSprite%="sfile_7f4;Pptr_hand,4,0;R2"
  7759. *      $
  7760. text(saveW%,4)="Default query"
  7761. 6      
  7762. shade(saveW%,4,
  7763. deselect(saveW%,4)      
  7764.       
  7765.  "Save selection":
  7766. 5      $SaveName%=$database%+".PrintRes.Selection"
  7767. 3      $SaveSprite%="sfile_7f3;Pptr_hand,4,0;R2"
  7768. .      $
  7769. text(saveW%,4)="Default selection"
  7770. 0      
  7771. shade(saveW%,4,
  7772. deselect(saveW%,4)
  7773.        
  7774.  "Display selection":
  7775. J      fieldsM%=
  7776. field_menu(items%,2+(printorder$="")):handle%=fieldsM%
  7777. /      item%=printM%+28+9*24:item%!4=handle%
  7778.         
  7779.     savefunc$=choice$(2)
  7780. 4    
  7781.  "Validation":
  7782. make_table_menu(TabsLoaded$)
  7783. "    
  7784.  "Index":
  7785. make_index_menu
  7786.  "Copy as":
  7787.     $SaveName%="!NewName"
  7788. 1    $SaveSprite%="snew_appl;Pptr_hand,4,0;R2"
  7789.     savefunc$=choice$(1)
  7790.  "Export selected":
  7791. 3    $SaveName%=$database%+".PrintJobs.Selected"
  7792. 1    $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  7793.     savefunc$=choice$(1)
  7794.  designM%:
  7795.  choice$(1) 
  7796.  "Save form file":
  7797. %    $SaveName%=$database%+".Form"
  7798.     1    $SaveSprite%="sfile_7f2;Pptr_hand,4,0;R2"
  7799.     savefunc$=choice$(1)
  7800.  tableM%:
  7801.  choice$(1) 
  7802.  "Save":
  7803. 4    $SaveName%=$database%+".ValTables."+$tableM%
  7804. 1    $SaveSprite%="sfile_7f1;Pptr_hand,4,0;R2"
  7805.     savefunc$="Save table"
  7806.  "Save as CSV":
  7807. H    $SaveName%=$database%+".PrintJobs."+
  7808. set_up_save_box(1)+$tableM%
  7809. 3    savefunc$="Save table as CSV":writetable%=
  7810.  listM%:
  7811.  choice$(1) 
  7812.  "Save as text":
  7813.     $SaveName%=TextName$
  7814. 1    $SaveSprite%="sfile_fff;Pptr_hand,4,0;R2"
  7815.     savefunc$=choice$(1)
  7816.  "Wimp_CreateSubMenu",,handle%,xmin%,ymax%
  7817. help_message(task%,your_ref%,wi%,ic%)
  7818.  T%,C%
  7819.  T%=0 
  7820.  LastTable%
  7821.  wi%=tableW%(T%) 
  7822.  Tablenumber%=T%
  7823. &!Scroller%=
  7824. scroller_num2(wi%)
  7825.  wi% 
  7826. help("HelpPbase")
  7827.  bannerW%:
  7828.  Do nothing
  7829.  listW%:
  7830. help("HelpList")
  7831.  tableW%(Tablenumber%):
  7832. help("HelpTable")
  7833.  scrollerW%(Scroller%):
  7834. help("HelpScroller")
  7835.  mainW%:
  7836. /-    
  7837.  ic%<0:
  7838.  present%=7 
  7839. help("main?")
  7840.  (ic% 
  7841.  2)=1:
  7842.     field%=(ic%+1) 
  7843.     C%=chartype%(field%)
  7844.  hide%?field%=0 
  7845.       s$="main"+
  7846. 5G      
  7847. phone(field%) 
  7848.  s$+=","+
  7849. msg("phone,"+
  7850. (DialDelay% 
  7851.  100))
  7852. 6*      
  7853.  C%=5 
  7854.  s$+="_"+
  7855. (len%(field%))
  7856. 7;      
  7857.  mandatory%?field%=1 
  7858.  s$+=","+
  7859. msg("mandatory")
  7860. 82      
  7861.  C%>67 
  7862.  C%<79 
  7863.  s$+=","+
  7864. msg("update")
  7865. 9.      
  7866.  C%>8 
  7867.  C%<32 
  7868.  s$="keypad"+
  7869. (C%-9)
  7870. :6      
  7871.  present%=7 
  7872. help(s$) 
  7873. help("maindrag")
  7874. ;        
  7875.  pselectW%:
  7876. help("Pselect")
  7877.  infoW%:
  7878. help("info"+
  7879. (ic%))
  7880.  miscW%:
  7881. help("misc"+
  7882. (ic%))
  7883.  relateW%:
  7884. help("relate"+
  7885. (ic%))
  7886.  accessW%:
  7887. help("access"+
  7888. (ic%))
  7889.  keypadW%:
  7890. help("keypad"+
  7891. (ic%))
  7892.  searchW%:
  7893. help("search"+
  7894. (ic%))
  7895.  filterW%:
  7896. help("filter"+
  7897. (ic%))
  7898.  queryW%:
  7899. help("query"+
  7900. (ic%))
  7901.  moveW%:
  7902. help("move"+
  7903. (ic%))
  7904.  calcW%:
  7905. help("calc"+
  7906. (ic%))
  7907.  sizeW%:
  7908. help("size"+
  7909. (ic%))
  7910.  matchW%:
  7911. help("match"+
  7912. (ic%))
  7913.  tabcreateW%:
  7914. help("tabcreate"+
  7915. (ic%))
  7916.  changeW%:
  7917. help("change"+
  7918. (ic%))
  7919.  passW%:
  7920. help("passwd"+
  7921. (ic%))
  7922.  aclW%:
  7923. help("acl"+
  7924. (ic%))
  7925.  saveW%:
  7926. help("save"+
  7927. (ic%))
  7928.  savesubW%:
  7929. help("savesub"+
  7930. (ic%))
  7931.  printW%:
  7932. help("print"+
  7933. (ic%))
  7934.  printerW%:
  7935. help("printer"+
  7936. (ic%))
  7937.  createW%:
  7938. help("create"+
  7939. (ic%))
  7940.  scrollW%:
  7941. help("scroll")
  7942.  prefsW%:
  7943. help("prefs"+
  7944. (ic%))
  7945.  csvW%:
  7946. help("csv"+
  7947. (ic%))
  7948.  fkeyW%:
  7949. help("fkey"+
  7950. (ic%))
  7951.  helpW%:
  7952. help("help"+
  7953. (ic%))
  7954.  keyW%:
  7955. help("key"+
  7956. (ic%))
  7957.  colW%:
  7958. help("col"+
  7959. (ic%))
  7960.  linkW%:
  7961. help("link"+
  7962. (ic%))
  7963.  reformW%:
  7964. help("reform"+
  7965. (ic%))
  7966.  mergebaseW%:
  7967. help("mergebase"+
  7968. (ic%))
  7969.  mergeW%:
  7970. help("merge"+
  7971. (ic%))
  7972.  gridW%:
  7973. help("grid"+
  7974. (ic%))
  7975.  markW%:
  7976. help("mark"+
  7977. (ic%))
  7978.  extracalcW%:
  7979. help("extracalcs"+
  7980. (ic%))
  7981.  mergecomW%:
  7982. help("mergecom"+
  7983. (ic%))
  7984. menu_help
  7985. menu_help
  7986.  ptr%,ch$,choice$
  7987.  "Wimp_GetMenuState",,menhelpblock%
  7988. ptr%=0
  7989.  menhelpblock%!ptr%<>-1
  7990.   ch$=
  7991. (menhelpblock%!ptr%)
  7992. (ch$)=2 
  7993.  ch$+="_"
  7994.   choice$+=ch$
  7995.   ptr%+=4
  7996.  menuhandle% 
  7997.  iconbarM%:
  7998. help("iconbar"+choice$)
  7999.  mainM%:
  8000. help("mainmen"+choice$)
  8001.  designM%:
  8002. help("design"+choice$)
  8003.  keystrokeM%:
  8004. help("keystroke"+choice$)
  8005.  mergecomM%:
  8006. help("mergemen"+choice$)
  8007. help(token$)
  8008. !block%=256
  8009. block%!4=task%
  8010. block%!12=your_ref%
  8011. block%!16=&503
  8012. $(block%+20)=
  8013. msg(token$)
  8014.  "Wimp_SendMessage",17,block%,block%!4
  8015.  File saving --------------------------------------------------------
  8016. export_selected(Form$)
  8017.  I%,F%,P%,F$
  8018. GSHsaveptr%=
  8019. extend_named_sliding_block(saveanchor%,Length%+fields%)
  8020. P%=SHsaveptr%
  8021.  I%=1 
  8022. (Form$)-1 
  8023.   F%=
  8024. fnum(
  8025. Form$,I%,2))
  8026.   F$=$Rf%(F%)+
  8027.   $P%=F$:P%+=
  8028. (Start%=SHsaveptr%:End%=P%:Type%=&fff
  8029. scrap_block(saveanchor%)
  8030. save_all_tables
  8031.  name$
  8032.  "Hourglass_On"
  8033. Tablenumber%=0
  8034.  Tablenumber%<=LastTable%
  8035.    name$=table$(Tablenumber%)
  8036. name$,1)<>"*" 
  8037. )    f$=$database%+".ValTables."+name$
  8038. c    t$=
  8039. table_info(Tablenumber%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8040. E    Start%=SHtabptr%(Tablenumber%):End%=Start%+offset%+Rows%*Rec%
  8041. "    
  8042. save(f$,&7f1,Start%,End%)
  8043.   Tablenumber%+=1
  8044.  "Hourglass_Percentage",Tablenumber%*100 
  8045.  (LastTable%+1)
  8046.  "Hourglass_Off"
  8047. save(f$,ft%,start%,end%)
  8048.  leaf$,L$,R$,S$,swap%
  8049. leaf$=
  8050. leaf(f$)
  8051. f$,9)="Powerbase" 
  8052. softerror("",129):
  8053.  writingtext% 
  8054.  ft% 
  8055.  savefunc$="Copy as" 
  8056. $    
  8057. leaf($database%))=0 
  8058. 8      
  8059.  "OS_CLI","Copy "+$database%+" "+f$+" ~C~VR"
  8060. -      
  8061. copy_database_spritefile(f$,leaf$)
  8062.       
  8063. softerror("",183)
  8064.         
  8065.         
  8066.  "OS_File",8,f$
  8067. $    
  8068.  "OS_File",8,f$+".Indexes"
  8069. &    
  8070.  "OS_File",8,f$+".ValTables"
  8071. "    
  8072.  "OS_File",8,f$+".Menus"
  8073. %    
  8074.  "OS_File",8,f$+".PrintRes"
  8075. &    
  8076.  "OS_File",8,f$+".PrintJobs"
  8077. &    
  8078.  "OS_File",8,f$+".UserFuncs"
  8079. K    
  8080.  "OS_CLI","Copy <PBase$Dir>.Resources.Temp.!Run "+f$+".!Run ~C~V"
  8081. F    
  8082.  "OS_CLI","Copy <PBase$Dir>.Resources.Info "+f$+".Data ~C~V"
  8083. +    
  8084. copy_database_spritefile(f$,leaf$)
  8085.       
  8086.  reformat%>0:
  8087.       $Reformatted%=f$
  8088.       
  8089.  reformat% 
  8090.         
  8091. D        
  8092.  "OS_CLI","Copy "+$database%+".Form "+f$+".Form ~C~VF"
  8093.         
  8094. get_it_in(f$)
  8095.          
  8096. open_window(mainW%)
  8097.         
  8098. complete(6)
  8099. ;        
  8100. selected(reformW%,11) 
  8101. softerror("",160)
  8102.         
  8103. >        
  8104.  "OS_CLI","Copy "+$Newform%+" "+f$+".Form ~C~VF"
  8105.         
  8106. do_reformat
  8107.       
  8108. D      
  8109.  mergefiles%:
  8110. merge_files($
  8111. text(mergebaseW%,3),f$,file%)
  8112. &      
  8113.  export%:
  8114. export_subset(f$)
  8115.       
  8116.  csvconv%:
  8117.       
  8118.  SHformptr%=0 
  8119. H        SHformptr%=
  8120. extend_named_sliding_block(formanchor%,SHclaim%)
  8121.         Fptr%=SHformptr%
  8122. $        fields%=0:Fieldnumber%=0
  8123. $        fields%=
  8124. get_form(Fptr%)
  8125.       
  8126.       
  8127.       
  8128. lit(iconbarM%,1,
  8129.       
  8130. get_it_in(f$)
  8131.       
  8132. open_window(mainW%)
  8133.       
  8134.  SHformptr%=0 
  8135. H        SHformptr%=
  8136. extend_named_sliding_block(formanchor%,SHclaim%)
  8137.         Fptr%=SHformptr%
  8138. $        fields%=0:Fieldnumber%=0
  8139.       
  8140.         
  8141. close_window(saveW%)
  8142.  &7f2:
  8143. save_form(f$)
  8144.  &7f5:
  8145. save_options(printW%,printerW%,f$)
  8146.  &dfe:
  8147. 6    
  8148.  writetable%:
  8149. table_to_csv(Tablenumber%,f$)  
  8150. 7    
  8151.  writescroller%:
  8152. scroller_to_csv(Scroller%,f$)
  8153. 9    
  8154. (-1) 
  8155. write_csv(f$,REC%) 
  8156. write_csv(f$,-1)
  8157. $    
  8158.  leaf$="Log" 
  8159.  leaf$="Acl":
  8160. -    L$="Set "+leaf$+"$Dir "+leafnamepath$
  8161. 3    
  8162.  leaf$="Log" 
  8163. close_log("<Log$Dir>.Log")
  8164. G    
  8165.  leaf$="Acl" 
  8166.  acl%=
  8167.  "OS_CLI","Rename <Acl$Dir>.Acl "+f$
  8168.  "OS_CLI",L$
  8169. E    
  8170.  "OS_CLI","Rename "+$database%+".!Run "+$database%+".!Temp"
  8171. 9    F=
  8172. ($database%+".!Temp"):F1=
  8173. ($database%+".!Run")
  8174.         
  8175.       S$=
  8176.       
  8177.         
  8178. S$,7)="Set Log":
  8179. 5        
  8180.  leaf$="Log" 
  8181. #F1,L$:swap%=
  8182. #F1,S$
  8183.         
  8184. S$,7)="Set Acl":
  8185. 5        
  8186.  leaf$="Acl" 
  8187. #F1,L$:swap%=
  8188. #F1,S$
  8189.          
  8190. S$,3)="Run":R$=S$
  8191.         
  8192. #F1,S$
  8193.       
  8194.  swap% 
  8195. #F1,L$
  8196. #F1,R$
  8197. &    
  8198. close_file(F):
  8199. close_file(F1)
  8200. /    
  8201.  "OS_File",18,$database%+".!Run",&feb
  8202. 1    
  8203.  "OS_CLI","Remove "+$database%+".!Temp"
  8204. G    
  8205.  leaf$="Log" 
  8206. set_icon(passW%,16,
  8207. mouse(0,0,4,passW%,4)  
  8208.  savetofile%:
  8209.     texthandle%=
  8210.      
  8211.  "OS_File",18,f$,Type%
  8212. I    writingtext%=
  8213.  Make sure we can't re-enter this PROC until done
  8214. "    
  8215. do_it(Search$,displayed%)
  8216.     writingtext%=
  8217. +    
  8218.  "OS_File",10,f$,ft%,,start%,end%
  8219.     !    
  8220. scrap_block(saveanchor%)
  8221. ramwarn%=
  8222. getstr(p%)
  8223.  ?p%>31
  8224.   p$+=
  8225. (?p%)
  8226.   p%+=1
  8227.  Validation tables ----------------------------------------------------
  8228. tabcreate_click(wi%,ic%,b%)
  8229.  I%,L%,head$,tablen%,width$,max%,row%,y%,headlen%,col%,z%,lim%
  8230.  "Hourglass_Smash":
  8231. wimp_error(
  8232.  (b% 
  8233.  %111)=4 
  8234.  z%=1 
  8235.  z%=-1
  8236.  %111 
  8237.  1,4:
  8238.  ic% 
  8239.     row%=
  8240. ($tabcol%)
  8241.  row%>MaxCols% 
  8242. $&      
  8243. softerror(
  8244. (MaxCols%+1),42)
  8245.       row%=MaxCols%
  8246.       $tabcol%=
  8247. (row%)
  8248.       
  8249. redraw_icon(wi%,8)
  8250. (        
  8251. )%    
  8252. set_caret(0,scrollW%,row%*2)
  8253. *)    
  8254.  row%<3 
  8255.  y%=0 
  8256.  y%=-(row%-2)*44
  8257. +9    !block%=scrollW%:
  8258.  "Wimp_GetWindowState",,block%
  8259. ,1    block%!24=y%:
  8260.  "Wimp_OpenWindow",,block%
  8261.  13,14:
  8262. .@    col%=
  8263. get_icon_cols(wi%,ic%):fg%=col% 
  8264.  16:bg%=col% 
  8265. /I    
  8266. selected(wi%,11) 
  8267.  fg%=(fg%+z%+16) 
  8268.  bg%=(bg%+z%+16) 
  8269. 0*    
  8270. set_icon_cols(wi%,ic%,fg%+bg%*16)
  8271. 2J    start$="new"+
  8272. get_icon_cols(wi%,13)*256+
  8273. get_icon_cols(wi%,14))
  8274. 3C    name$=$
  8275. text(wi%,0):
  8276.  name$="" 
  8277.  moan_err%,
  8278. msg("Err103")
  8279. 4E    Rows%=
  8280. text(wi%,1)):
  8281.  Rows%=0 
  8282.  moan_err%,
  8283. msg("Err104")
  8284.     LastTable%+=1
  8285.     Tablenumber%=LastTable%
  8286. 70    table$(Tablenumber%)=
  8287. name$,NameLength%)
  8288.     tablen%=
  8289. (start$)+1
  8290.     tablen%+=
  8291. (Rows%))+1
  8292.  "Hourglass_On"
  8293.     TabFields%=0
  8294. <,    
  8295. text(scrollW%,TabFields%*2)<>""
  8296. =.      width$=$
  8297. text(scrollW%,TabFields%*2)
  8298.       tablen%+=
  8299. (width$)+1
  8300. ?,      tabfieldlen%(TabFields%)=
  8301. (width$)
  8302. @*      Rec%+=tabfieldlen%(TabFields%)+1
  8303. A/      head$=$
  8304. text(scrollW%,TabFields%*2+1)
  8305. BW      
  8306. (head$)>tabfieldlen%(TabFields%) 
  8307.  LastTable%-=1:
  8308.  moan_err%,
  8309. msg("Err38")
  8310.       headlen%+=
  8311. (head$)+1
  8312.       TabFields%+=1
  8313. E        
  8314.     TabFields%-=1
  8315. G3    
  8316.  TabFields%<0 
  8317.  moan_err%,
  8318. msg("Err112")
  8319. H9    tablen%+=(
  8320. (TabFields%))+1+headlen%+Rows%*Rec%)
  8321. IM    SHtabptr%(Tablenumber%)=
  8322. claim_page(tabanchor%(Tablenumber%),tablen%)
  8323. J)    SHtabptr%=SHtabptr%(Tablenumber%)
  8324. K4    $SHtabptr%=start$:SHtabptr%+=
  8325. ($SHtabptr%)+1
  8326. L6    $SHtabptr%=
  8327. (Rows%):SHtabptr%+=
  8328. ($SHtabptr%)+1
  8329. M;    $SHtabptr%=
  8330. (TabFields%):SHtabptr%+=
  8331. ($SHtabptr%)+1
  8332.  I%=0 
  8333.  TabFields%
  8334. OC      $SHtabptr%=
  8335. (tabfieldlen%(I%)):SHtabptr%+=
  8336. ($SHtabptr%)+1
  8337.  I%=0 
  8338.  TabFields%
  8339. RG      $SHtabptr%=$
  8340. text(scrollW%,I%*2+1):SHtabptr%+=
  8341. ($SHtabptr%)+1
  8342.  row%=1 
  8343.  Rows%
  8344.       
  8345.  I%=0 
  8346.  TabFields%
  8347. V7        $SHtabptr%="":SHtabptr%+=tabfieldlen%(I%)+1
  8348.       
  8349.  row%
  8350.  "Hourglass_Off"
  8351. Z%    
  8352. show_table(Tablenumber%,0,0)
  8353. ["    
  8354. text(wi%,2)="Modify" 
  8355. \:      
  8356. write_back_to_table(OldTable%,Tablenumber%,wi%)
  8357. ]'      table$(OldTable%)=
  8358. "*"+name$)
  8359. ^       P%=
  8360. TabsLoaded$,name$)
  8361. _5      
  8362. TabsLoaded$,P%,
  8363. (name$))=table$(OldTable%)
  8364. `'      
  8365. close_it(tableW%(OldTable%))
  8366. a        
  8367.     TabsLoaded$+=","+name$
  8368. c%    
  8369. make_table_menu(TabsLoaded$)
  8370. d1    
  8371. close_it(wi%):
  8372. restore_caret(starthere%)
  8373. asterisk(
  8374. fK    
  8375. close_it(wi%):
  8376. restore_caret(returnto%):$
  8377. text(wi%,2)="Create"
  8378. renew_tables
  8379. display(key%,addr)
  8380. modify_table(T%,wi%)
  8381.  I%,Rows%,Rec%,L%,TabFields%,head$,cols%
  8382. oUt$=
  8383. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8384. text(wi%,2)="Modify"
  8385. text(wi%,0)=table$(T%)
  8386. text(wi%,1)=
  8387. (Rows%)
  8388. $tabcol%="0"
  8389.  I%=0 
  8390.  MaxCols%*2+1
  8391. text(scrollW%,I%)=""
  8392.  I%=0 
  8393.  TabFields%
  8394. x/  $
  8395. text(scrollW%,I%*2)=
  8396. (tabfieldlen%(I%))
  8397. yI  $
  8398. text(scrollW%,I%*2+1)=$
  8399. text(tableW%(T%),Rows%*(TabFields%+1)+I%)
  8400.  colours$="" 
  8401.  colours$="2807"
  8402. cols%=
  8403. ("&"+colours$)
  8404. set_icon_cols(wi%,13,cols% 
  8405.  256)
  8406. set_icon_cols(wi%,14,cols% 
  8407.  256)
  8408. OldTable%=T%
  8409. open_window(wi%):
  8410. set_caret(0,wi%,0)
  8411. redraw(wi%):
  8412. redraw(scrollW%)
  8413. write_back_to_table(old%,new%,wi%)
  8414.  row%,column%,P%,N%,I%,ic%
  8415. table_info(old%,oldRows%,oldTabFields%,Rec%,tabfieldlen%(),oldoffset%,oldheading%,colours$)
  8416. P%=oldheading%
  8417. tabhead$()=""
  8418.  I%=0 
  8419.  oldTabFields%
  8420. %  tabhead$(I%,0)=$P%:P%+=
  8421. ($P%)+1
  8422.  I%=0 
  8423.  TabFields%
  8424. ,  tabhead$(I%,1)=$
  8425. text(scrollW%,2*I%+1)
  8426.  oldRows%<=Rows% 
  8427.  N%=oldRows%-1 
  8428.  N%=Rows%-1
  8429.  "Hourglass_On"
  8430.  row%=0 
  8431. -  P%=SHtabptr%(old%)+oldoffset%+row%*Rec%
  8432.  column%=0 
  8433.  oldTabFields%
  8434.     I%=-1
  8435.         
  8436.       I%+=1
  8437. <    
  8438.  tabhead$(I%,1)=tabhead$(column%,0) 
  8439.  I%>TabFields%
  8440.  I%<=TabFields% 
  8441. $      ic%=row%*(TabFields%+1)+I%
  8442. K      $
  8443. text(tableW%(new%),ic%)=
  8444. buffer_length(tableW%(new%),ic%))
  8445. %      P%+=tabfieldlen%(column%)+1
  8446.         
  8447.  column%
  8448.  row%
  8449.  "Hourglass_Off"
  8450. text(wi%,2)="Create"
  8451. redraw(tableW%(new%))
  8452. clear_table(T%)
  8453. confirm(
  8454. msg("Err47"))=
  8455.  R%,F%,ind%,Rows%,TabFields%,start%,Rec%
  8456. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8457. %start%=SHtabptr%(T%)+offset%-Rec%
  8458.  R%=1 
  8459.  Rows%
  8460.   ind%=start%+R%*Rec%
  8461.  F%=0 
  8462.  TabFields%
  8463. )    $ind%="":ind%+=tabfieldlen%(F%)+1
  8464. redraw(tableW%(T%))
  8465. asterisk(
  8466. show_table(T%,x%,y%)
  8467.  ind%,start%,dflags%,hflags%,c%,I%,pos%,p$,t$,B%,tablefield%,offset%,heading%,colours$,width%,OK%
  8468. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8469. ;NewTab%=(t$="
  8470. "):extra%=-NewTab%*(Rows%*(TabFields%+1))
  8471.  T%<0 
  8472. /tablen%=
  8473. sliding_block_size(tabanchor%(T%))
  8474.  SHundoptr%(T%)<=0 
  8475.  SHundoptr%(T%)=
  8476. extend_named_sliding_block(undoanchor%(T%),tablen%)
  8477.  "Wimp_TransferBlock",mytask%,SHtabptr%(T%),mytask%,SHundoptr%(T%),tablen%
  8478.  tableW%(T%)>0 
  8479. text(tableW%(T%),0) 
  8480. %    
  8481.  SHtabptr%(T%)+offset%:OK%=
  8482. B    
  8483. :!block%=tableW%(T%):
  8484.  "Wimp_DeleteWindow",,block%:OK%=
  8485.  OK% 
  8486. open_window(tableW%(T%))
  8487.   name$=table$(T%)
  8488.   $Tablename%=name$
  8489.   $tableM%=name$
  8490.    ind%=SHtabptr%(T%)+offset%
  8491.  "Wimp_OpenTemplate",,"<Pbase$Dir>.Resources.Templates"
  8492.   B%=buff%
  8493.  "Wimp_LoadTemplate",,block%,buff%,endbuff%,-1,"table",0 
  8494.  ,,buff%
  8495.  NewTab% 
  8496. (name$)+1 
  8497. (t$)+1
  8498.   buff%+=L%:block%!80=L%
  8499.  "Wimp_CloseTemplate"
  8500. %  block%!28=block%!28 
  8501.  &AFFFFFFF
  8502. 1    
  8503.  (Rec%+TabFields%+9)*16<1136 
  8504.  Rows%<16:
  8505. C    
  8506.  (Rec%+TabFields%+9)*16<1136:block%!28=block%!28 
  8507.  (1<<28)
  8508. 0    
  8509.  Rows%<16:block%!28=block%!28 
  8510.  (1<<30)
  8511. 1    
  8512. :block%!28=block%!28 
  8513.  ((1<<28)+(1<<30))
  8514.  "Wimp_CreateWindow",,block% 
  8515.  tableW%(T%)
  8516. R  TabTitle%(T%)=block%!72:
  8517.  NewTab% 
  8518.  $TabTitle%(T%)=name$ 
  8519.  $TabTitle%(T%)=t$
  8520.  "Hourglass_On"
  8521.  colours$="" 
  8522.  colours$="2807"
  8523.   cols%=
  8524. ("&"+colours$)
  8525. +  hflags%=&0000A535+((cols% 
  8526.  256)<<24)
  8527. +  dflags%=&0000A535+((cols% 
  8528.  256)<<24)
  8529.  row%=1 
  8530.  Rows%
  8531.     pos%=72
  8532.  I%=0 
  8533.  TabFields%
  8534. 8      width%=
  8535. guess_width(tabfieldlen%(I%),2,width%)
  8536. z      R%=
  8537. create_icon(0,tableW%(T%),pos%,-row%*44-4+44*NewTab%,width%+2,48,dflags%,"",ind%,writep%,tabfieldlen%(I%)+1)
  8538.       pos%+=width%
  8539. "      ind%+=tabfieldlen%(I%)+1
  8540. 2    
  8541.  "Hourglass_Percentage",row%*100 
  8542.  Rows%
  8543.  row%
  8544.  NewTab% 
  8545.     pos%=72
  8546.  I%=0 
  8547.  TabFields%
  8548. 8      width%=
  8549. guess_width(tabfieldlen%(I%),2,width%)
  8550. g      R%=
  8551. create_icon(0,tableW%(T%),pos%,-48,width%+2,48,hflags%,"",heading%,-1,tabfieldlen%(I%)+1)
  8552.       pos%+=width%
  8553. "      heading%+=
  8554. ($heading%)+1
  8555.  "Hourglass_Off"
  8556.   p$=printrel$(T%)
  8557.  p$<>"" 
  8558.  I%=1 
  8559. (p$) 
  8560. "      tablefield%=
  8561. p$,I%,3))
  8562. 1      
  8563. select(tableW%(T%),tablefield%+extra%)
  8564. ,  width%=
  8565. guess_width(Rec%,2,width%)+112
  8566. /  !block%=0:block%!4=-Rows%*44-4+44*NewTab%
  8567. !  block%!8=width%:block%!12=0
  8568.  "Wimp_SetExtent",tableW%(T%),block%
  8569.   !block%=tableW%(T%)
  8570.  "Wimp_GetWindowState",,block%
  8571.  x%=0 
  8572.  x%=(ScreenWidth%-width%) 
  8573.   block%!4=x%
  8574.   block%!12=block%!4+width%
  8575.  Rows%<20 
  8576. 2    
  8577.  y%=0 
  8578.  y%=ScreenHeight% 
  8579.  2-(Rows%*18+2)
  8580.     block%!8=y%
  8581. 0    block%!16=block%!8+Rows%*44+4-44*NewTab%
  8582.         
  8583. )    
  8584.  y%=0 
  8585.  y%=ScreenHeight% 
  8586.  2-362
  8587.     block%!8=y%
  8588. -    block%!16=block%!8+44*20+4-44*NewTab%
  8589.  "Wimp_OpenWindow",,block%
  8590. redraw(tableW%(T%))
  8591.  Access% 
  8592. set_caret(0,tableW%(T%),0)
  8593. renew_tables
  8594.  T%=0 
  8595.  MaxTabs%
  8596. #  SHtabptr%(T%)=!tabanchor%(T%)
  8597. %  SHundoptr%(T%)=!undoanchor%(T%)
  8598.  tableW%(T%)>0 
  8599.     !block%=tableW%(T%)
  8600. (    
  8601.  "Wimp_GetWindowState",,block%
  8602. G    
  8603.  ((block%!32) 
  8604.  (1<<16))>0 
  8605. show_table(T%,block%!4,block%!8)
  8606. restore_table(T%)
  8607. /tablen%=
  8608. sliding_block_size(tabanchor%(T%))
  8609.  "Wimp_TransferBlock",mytask%,SHundoptr%(T%),mytask%,SHtabptr%(T%),tablen%
  8610. redraw(tableW%(T%))
  8611. restore_tabfield
  8612.  source%,dest%
  8613.  "Wimp_GetCaretPosition",,block%:wi%=!block%:ic%=block%!4
  8614.  wi%=tableW%(Tablenumber%) 
  8615. &,  dest%=
  8616. text(tableW%(Tablenumber%),ic%)
  8617. 'D  source%=SHundoptr%(Tablenumber%)+dest%-SHtabptr%(Tablenumber%)
  8618.   $dest%=$source%
  8619. redraw_icon(tableW%(Tablenumber%),ic%)
  8620. sort_table(T%,field%)
  8621.  tablen%,ind%,Rec%,Rows%,row%,TabFields%,pos%,dest%
  8622. /Ytitle$=
  8623. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8624. 0,pos%=
  8625. table_field(field%,tabfieldlen%())
  8626. 1(ind%=SHtabptr%(T%)+offset%-Rec%+pos%
  8627.  row%=0 
  8628.  Rows%-1
  8629.   ind%+=Rec%
  8630.   block%!(row%*4)=ind%
  8631.  $ind%="" 
  8632.  $ind%="~"
  8633.  row%
  8634.  "OS_HeapSort",Rows%,block%,4
  8635. 8?SHsort%=
  8636. extend_named_sliding_block(sortanchor%,Rows%*Rec%)
  8637. dest%=SHsort%-Rec%
  8638.  row%=0 
  8639.  Rows%-1
  8640. ;&  ind%=block%!(row%*4):dest%+=Rec%
  8641.  $ind%="~" 
  8642.  $ind%=""
  8643.  "Wimp_TransferBlock",mytask%,ind%-pos%,mytask%,dest%,Rec%
  8644.  row%
  8645.  "Wimp_TransferBlock",mytask%,SHsort%,mytask%,SHtabptr%(T%)+offset%,Rows%*Rec%
  8646. scrap_block(sortanchor%)
  8647. redraw(tableW%(T%))
  8648. print_table(T%)
  8649.  printing% 
  8650.  indexing% 
  8651.  start%,ptr%,Line$,title$,rowsused%,Heading$,h$,column%
  8652. print_init("W")
  8653. HZTextName$=$database%+".PrintJobs."+
  8654. "Tab"+table$(T%),NameLength%):$SaveName%=TextName$
  8655. IYtitle$=
  8656. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8657. format$="vtab"
  8658. spacer$,"|")>0 
  8659.  spacer$="|"
  8660. NewTab%=(title$="
  8661. M'LenLine%=Lmargin%+Rec%+TabFields%-1
  8662.  LenLine%<Lmargin%+26 
  8663.  LenLine%=Lmargin%+26
  8664. O@maxhead%=0:hspace%=164:fspace%=126:PrintFields%=TabFields%+1
  8665.  column%=0 
  8666.  PrintFields%
  8667. Q=  Tab%(column%+2)=Tab%(column%+1)+tabfieldlen%(column%)+1
  8668.  column%
  8669. end_line
  8670. send_title("Validation table")
  8671. send_title("Name: "+table$(T%))
  8672. send_title(
  8673.  NewTab% 
  8674.  column%=0 
  8675.  TabFields%
  8676. Y;    h$=$
  8677. text(tableW%(T%),Rows%*(TabFields%+1)+column%)
  8678. Z:    Heading$+=h$+
  8679. tabfieldlen%(column%)-
  8680. (h$)," ")+" "
  8681.  column%
  8682. send_title(
  8683. Heading$))
  8684. send_title(
  8685. title$,Rec%-1))
  8686.  "Hourglass_On"
  8687.  I%=1 
  8688.  Rows%
  8689. f'  start%=SHtabptr%(T%)+offset%-Rec%
  8690.   Line$=""
  8691.   ptr%=start%+I%*Rec%
  8692.  J%=0 
  8693.  TabFields%
  8694. jD    
  8695.  $ptr%<>"" 
  8696.  Line$+=$ptr%+
  8697. tabfieldlen%(J%)-
  8698. ($ptr%)+1," ")
  8699. k     ptr%+=tabfieldlen%(J%)+1
  8700.  Line$<>"" 
  8701.     rowsused%+=1
  8702. o'    
  8703. store_string(Line$,Lmargin%,
  8704.  "Hourglass_Percentage",I%*100 
  8705.  Rows%
  8706.  "Hourglass_Off"
  8707. send_title(
  8708. (Rows%)+" rows")
  8709. send_title(
  8710. (rowsused%)+" used")
  8711. screen_list
  8712. write_log(-1,"Table printed: "+table$(T%),"")
  8713. table_number(N$)
  8714.  T%,P%
  8715.  N$="" 
  8716.     T%=-1
  8717.   T%+=1
  8718.  table$(T%)=N$ 
  8719.  T%>LastTable%
  8720.  T%>LastTable% 
  8721. table_info(table%,
  8722.  rows%,
  8723.  columns%,
  8724.  recordlength%,colwidth%(),
  8725.  offset%,
  8726.  heading%,
  8727.  colours$)
  8728.  P%,Q%,I%,new%,S$
  8729. P%=SHtabptr%(table%):Q%=P%
  8730. S$=$P%
  8731. S$,3)="new" 
  8732.  new%=
  8733. :colours$=
  8734. S$,4):P%+=
  8735. ($P%)+1
  8736. rows%=
  8737. ($P%):P%+=
  8738. ($P%)+1
  8739.  columns%=
  8740. ($P%):P%+=
  8741. ($P%)+1
  8742. recordlength%=0
  8743.  I%=0 
  8744.  columns%
  8745. '  colwidth%(I%)=
  8746. ($P%):P%+=
  8747. ($P%)+1
  8748. $  recordlength%+=colwidth%(I%)+1
  8749. heading%=P%
  8750.  new% 
  8751.  I%=0 
  8752.  columns%
  8753.     P%+=
  8754. ($P%)+1
  8755.   offset%=P%-Q%
  8756.  P%+=
  8757. ($P%)+1:offset%=160
  8758.  new% 
  8759. =$heading%
  8760. table_field(F%,L%())
  8761.  I%,P%
  8762.  I%<F%
  8763.   P%+=L%(I%)+1
  8764.   I%+=1
  8765. trailing_number(
  8766.  exact%)
  8767. S$)="~" 
  8768.  exact%=
  8769.  exact%=
  8770.  S$<>"" 
  8771. S$))<58
  8772.     N$=
  8773. S$)+N$
  8774.     S$=
  8775.  N$="" 
  8776. leading_number(
  8777.  column%,
  8778.  S$<>"" 
  8779. S$,2,1)="#" 
  8780.     column%=
  8781.     S$=
  8782. S$,3)
  8783.  column%=0
  8784. (S$)<58
  8785.     N$=N$+
  8786. S$,1)
  8787.     S$=
  8788. S$,2)
  8789.  N$="" 
  8790. load_table(f$,show%)
  8791.  pos%,name$,d%,L%
  8792. f$)="!" 
  8793.  "OS_CLI","Rename "+f$+" "+
  8794. f$)+"+"
  8795.   f$=
  8796. f$)+"+"
  8797. name$=
  8798. leaf(f$):L%=
  8799. (name$)
  8800. TabsLoaded$,name$,7)=0 
  8801.  "OS_File",5,f$ 
  8802.  d%,,,,tablen%
  8803.  LastTable%=MaxTabs%-1 
  8804.  show% 
  8805. X      
  8806. softerror(
  8807. (MaxTabs%+1)+",validation tables,"+
  8808. (MaxTabs%)+",Tabs",32):show%=
  8809. :      
  8810. extratabs$,name$)=0 
  8811.  extratabs$+=name$+"\"
  8812.         
  8813.         
  8814.     LastTable%+=1
  8815. 6    
  8816.  LastTable%=MaxTabs%-1 
  8817. lit(validateM%,0,
  8818. Y    SHtabptr%(LastTable%)=
  8819. extend_named_sliding_block(tabanchor%(LastTable%),tablen%)
  8820. 1    
  8821.  "OS_File",255,f$,SHtabptr%(LastTable%)
  8822.      table$(LastTable%)=name$
  8823.     Tablenumber%=LastTable%
  8824.     TabsLoaded$+=","+name$
  8825.  Tablenumber%=
  8826. table_number(name$)
  8827.  show% 
  8828. show_table(Tablenumber%,0,0)
  8829. make_table_menu(menu$)
  8830.  ptr%,I%
  8831. ptr%=
  8832. clear_dynamic_menus
  8833.  LastTable%>=0 
  8834. ,  valtablesM%=
  8835. create_menu(ptr%,menu$)  
  8836. @  ptr%=validateM%+52:ptr%!4=valtablesM%:
  8837. lit(validateM%,1,
  8838. lit(validateM%,1,
  8839. link_to_table(wi%,ic%,b%)
  8840.  icon%
  8841. b%=(b% 
  8842.  %111)
  8843. make_table_menu(TabsLoaded$)
  8844.  2,4:
  8845.  ic%=13 
  8846. 8    
  8847. tick_one(valtablesM%,0,LastTable%,Tablenumber%)
  8848. .    
  8849. show_pop_up_menu(valtablesM%,wi%,ic%)
  8850.  %111 
  8851.  1,4:
  8852.  b%=4 
  8853.  z%=1 
  8854.  z%=-1
  8855.  ic% 
  8856. tcycle(-z%)
  8857. tcycle(+z%)
  8858. !    
  8859. fcycle(z%,fieldnum%)
  8860. "    
  8861. fcycle(-z%,fieldnum%)
  8862. $    
  8863. fcycle(z%,substitute%)
  8864. %    
  8865. fcycle(-z%,substitute%)
  8866.  icon%=10 
  8867. 2      
  8868. shade(linkW%,icon%,
  8869. selected(linkW%,9))
  8870.  icon%
  8871. $    
  8872.  ### Default action ###
  8873. "    icon%=field%(Fieldnumber%)
  8874. 1    
  8875. selected(linkW%,4) 
  8876.  $Tablename%<>"" 
  8877. 4      link$(Fieldnumber%)=$Tablename%+$fieldnum%
  8878. =      
  8879. selected(linkW%,15) 
  8880.  link$(Fieldnumber%)+="~"
  8881. V      
  8882. selected(linkW%,9) 
  8883.  link$(Fieldnumber%)=$substitute%+link$(Fieldnumber%)
  8884. &      
  8885.  chartype%(Fieldnumber%) 
  8886.         
  8887.  64,65,66,67:
  8888. B        link$(Fieldnumber%)=
  8889. (Scrcol%)+"#"+link$(Fieldnumber%)
  8890. ;        
  8891. colour_scroller(Fieldnumber%,Scrcol%,fcol%(8))
  8892. 3        
  8893. set_icon_cols(mainW%,icon%,fcol%(8))
  8894.       
  8895.       
  8896.     ?      link$(Fieldnumber%)="":
  8897. set_icon_cols(mainW%,icon%,7)
  8898. :      
  8899. colour_scroller(Fieldnumber%,Scrcol%,fcol%(10))
  8900. $      K%=
  8901. is_a_key(Fieldnumber%)
  8902.       
  8903.         
  8904.          
  8905.  key%:
  8906. colour(K%,1)
  8907.         
  8908. colour(K%,2)
  8909.       
  8910.         
  8911.     link$(0)="LOADED"
  8912. asterisk(
  8913. &    
  8914.  b%=4 
  8915. close_window(linkW%)
  8916. "    
  8917. close_window(linkW%)
  8918. tcycle(z%)
  8919.  LastTable%=-1 
  8920. Tablenumber%+=z%
  8921.  Tablenumber%>LastTable% 
  8922.  Tablenumber%=0
  8923.  Tablenumber%<0 
  8924.  Tablenumber%=LastTable%
  8925. $$Tablename%=table$(Tablenumber%)
  8926. redraw_icon(linkW%,0)
  8927. fcycle(z%,column%)
  8928. $_T$=
  8929. table_info(Tablenumber%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  8930. field%=
  8931. ($column%)
  8932. field%+=z%
  8933.  field%>TabFields% 
  8934.  field%=0
  8935.  field%<0 
  8936.  field%=TabFields%
  8937. $column%=
  8938. (field%)
  8939. redraw_icon(linkW%,2)
  8940. redraw_icon(linkW%,10)
  8941. link_status
  8942.  name$,field$,ic%,subst$,exact%,scrcol%
  8943. name$=link$(Fieldnumber%)
  8944. 1,field$=
  8945. trailing_number(name$,exact%))
  8946. set_icon(linkW%,15,exact%)
  8947. 3,subst$=
  8948. leading_number(scrcol%,name$))
  8949.  subst$="-1" 
  8950.  subst$="0"
  8951.  (name$<>"" 
  8952. TabsLoaded$,name$)>0) 
  8953. 6=  $Tablename%=name$:$fieldnum%=field$:$substitute%=subst$
  8954. 7'  Tablenumber%=
  8955. table_number(name$)
  8956. set_icon(linkW%,4,(scrcol%=0 
  8957.  scrcol%=Scrcol%))
  8958.   Tablenumber%=0
  8959. ;&  $Tablename%=table$(Tablenumber%)
  8960. deselect(linkW%,4):$fieldnum%="0"
  8961. set_icon(linkW%,9,subst$<>"0")
  8962.  ic%=10 
  8963. shade(linkW%,ic%,
  8964. selected(linkW%,9))
  8965. redraw_icon(linkW%,0):
  8966. redraw_icon(linkW%,2)
  8967. save_links
  8968.  link$(0)="LOADED" 
  8969. ($database%+".Link")
  8970.  F%=1 
  8971.  fields%
  8972. #F,link$(F%)
  8973. close_file(F)
  8974.  End of Validation table routines ------------------------------------
  8975. changes(key%,field%,Old$,New$,confirm%)
  8976.  M$,K%,P%,index%,zero%,target$,log$,numeric%,fi$
  8977. fi$=" "
  8978.  I%=0 
  8979. selected(queryW%,I%+6) 
  8980.  fi$+=
  8981. (I%)+"\"
  8982. fi$,"\")>0 
  8983.  fi$="s"+fi$
  8984. Z"target$=$Query%:Search$=
  8985. parse
  8986. [%target$=
  8987. replace(target$,",","\")
  8988.  New$="" 
  8989.  n$="<null>" 
  8990.  n$=New$
  8991. is_a_key(field%)
  8992. softerror("",144)
  8993.  key%:
  8994. softerror("",12)
  8995.  K%>0 
  8996. msg("Err189") 
  8997.  M$=""
  8998.  Old$<>"" 
  8999.  o$=" "+
  9000. msg("Err184")+Old$ 
  9001.  o$=""
  9002.  target$="" 
  9003.  target$=" "+
  9004. msg("Err190,"+fi$) 
  9005.  target$=" "+
  9006. msg("Err191,"+target$+","+fi$)
  9007.  chartype%(field%) 
  9008. fN    
  9009.  41,42,43,61,62:Old$=
  9010. pos_neg(field%,Old$):New$=
  9011. pos_neg(field%,New$)
  9012. gZ    
  9013.  New$<>"" 
  9014. "+-*/",
  9015. New$,1))>0 
  9016. New$,2))>0 
  9017.  n$=Tag$(field%)+n$:numeric%=
  9018. i'  target$=
  9019. replace(target$,",","\")
  9020. j>  log$=
  9021. msg("Err192,"+Tag$(field%)+","+n$+o$+target$+". ")
  9022.   target$=log$+M$
  9023.  confirm%=
  9024. confirm(target$)=
  9025. m)    subtotal%=
  9026. count_recs(key%,zero%)
  9027. n.    dbasehandle%=
  9028. ($database%+".Database")
  9029. o3    
  9030. scan_marked_subfiles("P%<>top",key%,5,1,
  9031. p!    
  9032. close_file(dbasehandle%)
  9033.     $Date%(file%)=
  9034. today
  9035.     date%?file%=1
  9036. display(key%,addr)
  9037. t,    
  9038.  K%>0 
  9039. remove_index(Index$(K%),
  9040. write_log(-1,log$,"")
  9041. asterisk(
  9042. is_a_key(F%)
  9043.  key%,flag%,J%
  9044. flag%=-1
  9045.  J%=0 
  9046. &    
  9047.  KF%(key%,J%)=F% 
  9048.  flag%=key%
  9049.   key%+=1
  9050.  flag%>=0 
  9051.  key%>Keys% 
  9052. =flag%
  9053. read(display%,N%,K%,R%,f$)
  9054.  I%,key%,dbasehandle%,V%,P%,C%,d%,path$
  9055. "dbasehandle%=
  9056. (f$+".Database")
  9057. F$()=field$()
  9058. %$Rf%(0)="":field$(0)="":key$()=""
  9059. #dbasehandle%=
  9060. (R%)*Length%
  9061.  I%=1 
  9062.  zerolen%?I%=0 
  9063.  field$(I%)=
  9064. #dbasehandle% 
  9065.  field$(I%)=""
  9066.   C%=chartype%(I%)
  9067. "    
  9068.  21,27,28,32,34,40,45,59:
  9069. M    
  9070.  $Rf%(I%) holds key legend or other important data. Don't overwrite!
  9071. :$Rf%(I%)=field$(I%)
  9072.  35,44:
  9073.  WithLeaf% 
  9074. 4      $
  9075. text(mainW%,field%(I%))=
  9076. leaf(link$(I%))
  9077. (      
  9078. text(mainW%,field%(I%))=""
  9079.         
  9080.  36,37,38:
  9081.  display% 
  9082. *      
  9083. set_blob_sprite(R%,I%,C%,path$)
  9084. )      
  9085.  displayit%?I%=1 
  9086.  design% 
  9087. %        
  9088.  "OS_File",5,path$ 
  9089. 3        
  9090.  d%>0 
  9091.  "OS_CLI","Filer_Run "+path$
  9092.       
  9093. 1    
  9094.  display% 
  9095. show_text_block(I%,R%)
  9096. .    
  9097.  display% 
  9098. show_picture(I%,R%)
  9099.  41,42,43:
  9100.  display% 
  9101. V      
  9102.  field$(I%)=" " 
  9103. select(mainW%,field%(I%)) 
  9104. deselect(mainW%,field%(I%))
  9105.         
  9106.  61,62:
  9107. 9    V%=
  9108. val(mainW%,field%(I%)):P%=
  9109. $V%,";S"):V%+=P%+1
  9110.  field$(I%) 
  9111.       
  9112. (0):$V%="no"
  9113.       
  9114.  " ":$V%="yes"
  9115. 4      
  9116.  C%=61 
  9117.  $V%="null" 
  9118.  $V%="dontcare"
  9119.         
  9120. (    
  9121.  R%=RA% 
  9122.  $Rf%(I%)=
  9123. (REC%)
  9124. 9    
  9125.  R%=RA% 
  9126. split_link(I%,R$,V$):$Rf%(I%)=R$
  9127. '    
  9128.  R%=RA% 
  9129.  $Rf%(I%)=
  9130. (    
  9131.  R%=RA% 
  9132.  $Rf%(I%)=
  9133. $,15)
  9134. 1    
  9135.  R%=RA% 
  9136.  $Rf%(I%)=
  9137. convert_date(2)
  9138. 1    
  9139.  R%=RA% 
  9140.  $Rf%(I%)=
  9141. convert_date(4)
  9142. #    
  9143.  R%=RA% 
  9144.  $Rf%(I%)=
  9145. '    
  9146.  R%=RA% 
  9147.  $Rf%(I%)=
  9148. )    
  9149.  R%=RA% 
  9150.  $Rf%(I%)=
  9151. $,5,2)
  9152. )    
  9153.  R%=RA% 
  9154.  $Rf%(I%)=
  9155. $,8,3)
  9156. J    
  9157.  R%=RA% 
  9158. $,8,3):P%=
  9159. Months$,M$):$Rf%(I%)=
  9160. ((P%+2) 
  9161. F    
  9162.  R%=RA% 
  9163. $,3):P%=
  9164. Days$,D$):$Rf%(I%)=
  9165. ((P%+2) 
  9166. *    
  9167.  R%=RA% 
  9168.  $Rf%(I%)=
  9169. $,12,4)
  9170.  display% 
  9171. .      f$=
  9172. filename($Rf%(I%),"PrintRes",-1)
  9173. &      Z%=
  9174. set_remote_sprite(I%,f$)
  9175. L      
  9176.  Z%>0 
  9177.  displayit%?I%=1 
  9178.  design% 
  9179.  "OS_CLI","Filer_Run "+f$
  9180. 0    
  9181.  64,65,66,67:
  9182. get_scroller(R%,I%,C%-63)
  9183. :    
  9184.  68,69,70,71,72,73,74,75,76,77,78:
  9185. set_now(C%,I%)
  9186.  key%=0 
  9187.  Keys%
  9188.     key$(key%)=
  9189. key(key%)
  9190.  key%
  9191. close_file(dbasehandle%)
  9192. cfield$()=field$()
  9193.  special%(1) 
  9194. (libfunc$+"_function(1)")
  9195. set_now(C%,I%)
  9196.  P%,D$,M$
  9197.  68:$Rf%(I%)=
  9198.  69:$Rf%(I%)=
  9199. $,15)
  9200.  70:$Rf%(I%)=
  9201. convert_date(2)
  9202.  71:$Rf%(I%)=
  9203. convert_date(4)
  9204.  72:$Rf%(I%)=
  9205.  73:$Rf%(I%)=
  9206.  74:D$=
  9207. $,3):P%=
  9208. Days$,D$):$Rf%(I%)=
  9209. ((P%+2) 
  9210.  75:$Rf%(I%)=
  9211. $,5,2)
  9212.  76:$Rf%(I%)=
  9213. $,8,3)
  9214.  77:M$=
  9215. $,8,3):P%=
  9216. Months$,M$):$Rf%(I%)=
  9217. ((P%+2) 
  9218.  78:$Rf%(I%)=
  9219. $,12,4)
  9220. update_calcs(N%)
  9221.  design% 
  9222.  N%>0 
  9223.  $Rf%(N%)=cfield$(N%) 
  9224.  I%,C%,L%,F,F$,Form$,S$,SF$,changed%,c%
  9225. GForm$=update$(N%):
  9226.  List of fields affected by a change in field N%
  9227.  Form$=0 
  9228. calc_error(F$,F%,visible$,real$):=
  9229.  I%=1 
  9230. (Form$)-1 
  9231.   F%=
  9232. fnum(
  9233. Form$,I%,2))
  9234.  F%<>N% 
  9235. &    
  9236. split_link(F%,real$,visible$)
  9237.  chartype%(F%) 
  9238. E      
  9239.  6:F=
  9240. (real$):F$=
  9241.  fix%(F%)<>0 
  9242. fix_point(F$,F%)
  9243. L      
  9244.  7:F$=
  9245. (real$):
  9246.  N%=0 
  9247. expand(F$,link$(F%),L%,SF$,c%):F$=SF$
  9248.         
  9249. (F$)<=len%(F%) 
  9250. *      $Rf%(F%)=F$:cfield$(N%)=$Rf%(N%)
  9251. 4      
  9252. redraw_icon(mainW%,field%(F%))           
  9253. .      
  9254.  F$(F%)<>F$ 
  9255.  F$(F%)=F$:changed%=
  9256.       
  9257.  moan_err%,""
  9258.         
  9259. "    changed%=
  9260. update_calcs(F%)
  9261. 9    
  9262.  Other computed fields might depend on this one!
  9263. =changed%
  9264. calc_error(F$,F%,V$,R$)
  9265. replace(V$,",","\"):R$=
  9266. replace(R$,",","\")
  9267.  Division by zero. Ignore - this error will often occur where
  9268.  a field used as a divisor has not yet been filled in
  9269. softerror(V$,73):
  9270.  No such field tag
  9271. softerror(V$,137):
  9272.  No such FN/PROC
  9273.  moan_err%:
  9274. softerror(F$+","+Tag$(F%),10)
  9275. softerror(
  9276. $+","+V$+","+R$,170)
  9277. check_record
  9278.  F%,flag%,S$,V$
  9279.  present%<7 
  9280.  nosave% 
  9281.  qbe% 
  9282.  F%=1 
  9283.  fields%
  9284.   V$=vtype$(chartype%(F%))
  9285. selected(prefsW%,47) 
  9286.  V$="E" 
  9287.       
  9288.  ?Rf%(F%)=32
  9289. !        $Rf%(F%)=$(Rf%(F%)+1)
  9290.       
  9291.         
  9292.  Check whether record has been changed (write to disc if so)...
  9293. 6    
  9294.  "E","T","C":
  9295.  $Rf%(F%)<>field$(F%) 
  9296.  flag%=
  9297. A    
  9298.  "X":
  9299.  chartype%(F%)=60 
  9300.  $Rf%(F%)<>field$(F%) 
  9301.  flag%=
  9302. A    
  9303.  "L":
  9304.  ScrollChanged% 
  9305. write_scroller(REC%,F%):flag%=
  9306.  ...and that all mandatory fields have been filled in
  9307.  V$="E" 
  9308. ;    
  9309.  $Rf%(F%)="" 
  9310.  mandatory%?F%=1 
  9311.  S$+=Tag$(F%)+"\" 
  9312.  flag% 
  9313. write(fields%,key%):
  9314. blob_deleterestore("D"):
  9315. asterisk(
  9316. selected(prefsW%,21) 
  9317.  Validation is turned off
  9318. key(0)="" 
  9319.  Don't report on mandatory fields if no primary key
  9320.  S$="" 
  9321. S$,"\")>0 
  9322.  S$="s "+S$ 
  9323.  S$=" "+S$
  9324. softerror(S$,61)
  9325. write(N%,k%)
  9326.  key%,newrec%
  9327. close_file(dbasehandle%):
  9328.  Access% 
  9329. softerror("",14):
  9330. close_file(dbasehandle%)
  9331.  template%=2 
  9332. write_dbase(RA%,N%,
  9333. ):template%=0:
  9334. PRI$=
  9335. key(0)
  9336.  PRI$="" 
  9337.  retry%=
  9338. confirm(
  9339. msg("Err202")):
  9340.  key$(0) 
  9341.  key%=0 
  9342.  Keys%
  9343.     KEY$=
  9344. key(key%)
  9345.     kl%=
  9346. (KEY$)
  9347. 8F    
  9348. insert(KEY$,key%,dupwarn%):
  9349.  KEY$="*Failed*" 
  9350.  moan_err%,""
  9351. 9!    key$(key%)=KEY$:newrec%=
  9352. :"    
  9353.  k%=key% 
  9354.  addr=nextfree%
  9355.  key%
  9356.  key%=0 
  9357.  Keys%
  9358.     KEY$=
  9359. key(key%)
  9360.  KEY$<>key$(key%) 
  9361. @[      
  9362.  key%=0 
  9363. confirm(
  9364. msg("Err48")) 
  9365. restore(1,fields%,"",-1):
  9366.  moan_err%,""
  9367. A"      
  9368. delete(key$(key%),key%)
  9369. B%      
  9370. insert(KEY$,key%,dupwarn%)
  9371.       
  9372.  KEY$="*Failed*" 
  9373.         KEY$=key$(key%)
  9374. E%        
  9375. restore(1,fields%,"",-1)
  9376. F'        
  9377. insert(KEY$,key%,dupwarn%)
  9378.         
  9379.  moan_err%,""
  9380.       
  9381.       key$(key%)=KEY$
  9382. J        
  9383.  key%
  9384. $Date%(file%)=
  9385. today
  9386. date%?file%=1
  9387.  newtree% 
  9388. write_dbase(REC%,N%,
  9389.  newrec% 
  9390.  k%>0 
  9391. rectify_address(k%)
  9392.  autobalance% 
  9393.  (REC% 
  9394. ($Every%))=0 
  9395.  key%=0 
  9396.  Keys%
  9397.       
  9398. balance(key%)
  9399.  key%
  9400. rectify_address(k%)
  9401.  special%(3) 
  9402. (libfunc$+"_function(3)")
  9403. rectify_address(key%)
  9404. S$=key$(key%)
  9405.  S$="" 
  9406.  null%(key%)=
  9407.  S$=ResKEY$:REC%=ResREC%
  9408.  case%(key%) 
  9409. u(S$)
  9410. a=val$=
  9411. type(key%):
  9412.  val$="VAL" 
  9413.  kl%=KL%(key%) 
  9414.  kl%=
  9415. addr=
  9416. search(S$,key%,2)
  9417. write_dbase(R%,N%,logchanges%)
  9418.  I%,F$,S$,dbasehandle%,flag%
  9419. g*dbasehandle%=
  9420. ($database%+".Database")
  9421. #dbasehandle%=R%*Length%
  9422.  logchanges% 
  9423.  newrec% 
  9424. kF    
  9425. write_log(R%,"New record: Subfile "+
  9426. (file%)+"  "+
  9427. key(0),"")
  9428. l-    
  9429. write_log(R%,logentry$,""):flag%=
  9430.  I%=1 
  9431.  chartype%(I%) 
  9432.  39,40:F$=""
  9433.  newrec% 
  9434.       F$=$Rf%(I%)
  9435.       
  9436. split_link(I%,R$,V$)
  9437.       S%=
  9438. w/      
  9439.  dontincrement%=
  9440.  S%+=1:F$=
  9441. (S%-1)
  9442. x       calc$(I%)=V$+"|"+
  9443.       
  9444.  F$=$Rf%(I%)
  9445. z        
  9446.     dontincrement%=
  9447.  58:F$=
  9448. :F$=$Rf%(I%)
  9449.  zerolen%?I%=0 
  9450. #dbasehandle%,F$
  9451.  flag%=
  9452.  F$<>field$(I%) 
  9453.  chartype%(I%)<>59 
  9454. %    
  9455.  F$="" 
  9456.  D$="<null>" 
  9457.  D$=F$
  9458. 5    
  9459.  field$(I%)="" 
  9460.  S$="<null>" 
  9461.  S$=field$(I%)
  9462. 2    
  9463. write_log(-1,Tag$(I%)+": "+S$,"---> "+D$)
  9464.   field$(I%)=F$
  9465. selected(prefsW%,44) 
  9466. readsmarray(dbasehandle%,R%)
  9467. write_csv_rec(R%,csvform$,autocsvhandle%)
  9468. close_file(dbasehandle%)
  9469. split_link(F%,
  9470.  L$,P%,F
  9471. L$=calc$(F%)
  9472. L$,1)="#":
  9473. /  P%=
  9474. L$,"#",2):V$=
  9475. L$,P%+1):R$=
  9476. L$,2,P%-2)
  9477. L$,"|")>0:
  9478. +  P%=
  9479. L$,"|"):V$=
  9480. L$,P%-1):R$=
  9481. L$,P%+1)
  9482. :R$="":V$=""
  9483. key(key%)
  9484. key2(key%,0)
  9485. key2(key%,loc%)
  9486.  I%,W%,P%,S$,W$,T$,pad$,chars%,pos%,word%,wd%,field%,numeric%
  9487.  I%=0 
  9488.   W%=KW%(key%,I%):W$=""
  9489.  W%>0 
  9490.     chars%=W% 
  9491.     pos%=(W%>>8) 
  9492.     word%=(W%>>16) 
  9493.     field%=KF%(key%,I%)
  9494.  chartype%(field%) 
  9495. 8      
  9496.  3,6,46,47,54,56,57,74,75,77,78,79:numeric%=
  9497.       
  9498. :numeric%=
  9499.         
  9500. :    
  9501.  loc%=0 
  9502.  S$=$Rf%(field%)+" " 
  9503.  S$=F$(field%)+" "
  9504.  numeric% 
  9505.       
  9506.  word% 
  9507.         
  9508.         
  9509. !          C$=
  9510. S$,1):S$=
  9511. S$,2)
  9512.            
  9513.  C$<>" " 
  9514.  W$+=C$
  9515.         
  9516.  S$=""
  9517.         
  9518.         wd%=0
  9519.         
  9520. :          P%=
  9521. S$," "):w$=
  9522. S$,P%-1):S$=
  9523. S$,P%+1):wd%+=1
  9524.         
  9525.  wd%=word% 
  9526.  S$=""
  9527.         
  9528.  wd%=word% 
  9529.  W$=w$
  9530.       
  9531.        
  9532.  chartype%(field%) 
  9533. 7        
  9534.  5,50,51,70,71,49,69,52,58,72,55,76,53,73:
  9535. ,        W$=
  9536. transform_date(KL%(key%),W$)
  9537.       
  9538.       
  9539.  pos% 
  9540.         
  9541.  0:W$=
  9542. W$,chars%)
  9543.          
  9544.  255:W$=
  9545. W$,chars%)
  9546. !        
  9547. W$,pos%,chars%)
  9548.       
  9549.       
  9550.  W$<>"" 
  9551. B        
  9552.  incspace%(key%)=
  9553.  word%>0 
  9554.  W$+=
  9555. chars%-
  9556. (W$)," ")
  9557.       
  9558.       
  9559.         
  9560.     T$+=W$
  9561.  T$<>"" 
  9562.  incspace%(key%)=
  9563.  pad$=" " 
  9564.  pad$="#"
  9565.    T$+=
  9566. KL%(key%)-
  9567. (T$),pad$)
  9568.  case%(key%) 
  9569. u(T$)
  9570. u(N$)
  9571.  I%,B%
  9572. $key=N$
  9573.  I%=0 
  9574. (N$)-1
  9575.   B%=key?I%
  9576.  B%>96 
  9577.  B%<123 
  9578.  key?I%=B% 
  9579.     =$key
  9580. l(N$)
  9581.  I%,B%
  9582. $key=N$
  9583.  I%=0 
  9584. (N$)-1
  9585.   B%=key?I%
  9586.  B%>64 
  9587.  B%<91 
  9588.  key?I%=B% 
  9589.     =$key
  9590. today
  9591.  Y$,M$,D$,M%,date$
  9592. $,14,2)
  9593. $,5,2)
  9594. $,8,3)
  9595. Months$,M$)+2) 
  9596.  M%<10 
  9597.  M$="0"+
  9598. (M%) 
  9599. &date$=D$+$datesep%+M$+$datesep%+Y$
  9600. =date$
  9601. date(key%)
  9602.  SHkeyptr%(key%)<=0 
  9603.  I%=0 
  9604.  date%?I%=1 
  9605. (    $(SHkeyptr%(key%)+8+9*I%)=
  9606. today
  9607.     $Date%(I%)=
  9608. today
  9609. check_date(F%,D$,place%,
  9610.  date$)
  9611.  I%,D%,M%,Y%,L%,P%,Q%,U$,d$,m$,y$
  9612.  L%=0 
  9613.  I%=1 
  9614.   C$=
  9615. D$,I%,1)
  9616.  C$<"0" 
  9617.  C$>"9" 
  9618.  P%=0 
  9619.  P%=I% 
  9620.  Q%=I%
  9621.  P%=0 
  9622.  Q%=0 
  9623. restore(F%,F%,
  9624. msg("Err102"),4):=
  9625. D$,P%-1))
  9626. D$,P%+1,Q%-P%-1))
  9627. D$,Q%+1))
  9628.  Y%<0 
  9629.  D%<1 
  9630. restore(F%,F%,"",4):=
  9631.  M%<1 
  9632.  M%>12 
  9633. restore(F%,F%,
  9634. msg("Err118"),4):=
  9635.  (Y% 
  9636.  400)=0:U$=leap$:
  9637.  Century year is leap year if divisible by 400
  9638.  (Y% 
  9639.  100)<>0 
  9640.  (Y% 
  9641.  4)=0:U$=leap$:
  9642.  otherwise not
  9643. :U$=nonleap$
  9644. U$,2*M%-1,2)
  9645. (DM$) 
  9646. restore(F%,F%,
  9647. msg("Err119,"+DM$),4):=
  9648. (D%):
  9649. (d$)=1 
  9650.  d$="0"+d$
  9651. (M%):
  9652. (m$)=1 
  9653.  m$="0"+m$
  9654. (Y%):
  9655. (y$)=1 
  9656.  y$="0"+y$
  9657. (y$)<>2 
  9658. (y$)<>4 
  9659. restore(F%,F%,
  9660. msg("Err120"),4):=
  9661. (y$)=4 
  9662.  len%(F%)<10 
  9663. y$,2)
  9664. (y$)=2 
  9665.  len%(F%)>=10 
  9666.  Y%<CentChange% 
  9667.  y$="20"+y$ 
  9668.  y$="19"+y$
  9669. &date$=d$+$datesep%+m$+$datesep%+y$
  9670.  place%=0 
  9671. (date$)>len%(F%) 
  9672. restore(F%,F%,
  9673. msg("Err7,"+date$),4):=
  9674.  place% 
  9675.  0:$Rf%(F%)=date$:
  9676. redraw_icon(mainW%,field%(F%))
  9677. text(searchW%,1)=date$:
  9678. redraw_icon(searchW%,1)
  9679. convert_date(L%)
  9680.  d$,m$,y$,M$,M%
  9681. $,5,2)
  9682. $,8,3)
  9683. Months$,M$)
  9684. M%=(P%+2) 
  9685. $ m$=
  9686. (M%):
  9687.  M%<10 
  9688.  m$="0"+m$
  9689. $,16-L%,L%)
  9690. &!=d$+$datesep%+m$+$datesep%+y$
  9691. transform_date(L%,K$)
  9692.  Y$,M$,D$,T$,DW$,S$,P%,V%
  9693.   V%=
  9694.     P%=
  9695. Months$,K$)
  9696.  P%>0 
  9697. 1"      K$=
  9698. ((P%+2) 
  9699.  3),2)
  9700. 2$      
  9701. Days$,K$)+2) 
  9702. 53    
  9703. K$,1)="0" 
  9704.  V%>7 
  9705.  S$=Months$ 
  9706.  S$=Days$
  9707.     K$=
  9708. S$,V%*3-2,3)
  9709.  5:K$=
  9710. days(K$))
  9711.  8:K$=
  9712. K$,2)+
  9713. K$,3,4)+
  9714. K$,2)
  9715. (K$)<100 
  9716. <!    K$=
  9717. K$,4)+
  9718. K$,3,4)+
  9719. K$,2)
  9720. =#    
  9721. K$,2)+
  9722. K$,5,4)+
  9723. K$,4)
  9724.   DW$=
  9725. K$,3):Y$=
  9726. K$,10,4)
  9727. A.  M$=
  9728. Months$,
  9729. K$,7,3))+2) 
  9730.  3),2)
  9731.   D$=
  9732. K$,5,2):T$=
  9733. K$,15,8)
  9734. C%  K$=Y$+$datesep%+M$+$datesep%+D$
  9735.  T$<>"" 
  9736.  K$+=$datesep%+T$
  9737. refresh_dates
  9738.  key%
  9739.  key%=0 
  9740.  Keys%
  9741. date(key%)
  9742.  key%
  9743. days(date$)
  9744.  Returns no. of elapsed days since 1 Jan 1900
  9745.  D%,M%,Y%
  9746.  date$="" 
  9747. date$,2))
  9748. date$,4,2))
  9749. date$,7))
  9750.  Y%<10:Y%+=2000
  9751.  Y%<100:Y%+=1900
  9752. Z;!ordinals%=0:ordinals%!4=0:ordinals%!8=0:ordinals%!12=1
  9753. [3ordinals%!16=D%:ordinals%!20=M%:ordinals%!24=Y%
  9754.  "Territory_ConvertOrdinalsToTime",-1,utctime%,ordinals%
  9755. =(utctime%!1) 
  9756.  33750
  9757. date(days%,L%)
  9758. `0$dateformat%="%DY"+$datesep%+"%MN"+$datesep%
  9759.  L%=8 
  9760.  $dateformat%+="%YR"+
  9761.  $dateformat%+="%CE%YR"+
  9762. utctime%!1=days%*33750
  9763.  "Territory_ConvertDateAndTime",-1,utctime%,datebuffer%,16,dateformat%
  9764. datebuffer%?L%=13
  9765. =$datebuffer%
  9766. check_time(
  9767.  time$,wi%,ic%)
  9768.  I%,P%,Q%,H%,M%,S%,C$
  9769.  I%=1 
  9770. (time$)
  9771.   C$=
  9772. time$,I%,1)
  9773.  C$<"0" 
  9774.  C$>"9" 
  9775.  P%=0 
  9776.  P%=I% 
  9777.  Q%=I%
  9778.  TimeFirst$ 
  9779.  "H":
  9780.  P%=0:H%=
  9781. (time$)
  9782. s-    
  9783.  Q%=0:H%=
  9784. (time$):M%=
  9785. time$,P%+1))
  9786. t;    
  9787. (time$):M%=
  9788. time$,P%+1)):S%=
  9789. time$,Q%+1))
  9790.  "S":
  9791.  P%=0:S%=
  9792. (time$)
  9793. y-    
  9794.  Q%=0:M%=
  9795. (time$):S%=
  9796. time$,P%+1))
  9797. z;    
  9798. (time$):M%=
  9799. time$,P%+1)):S%=
  9800. time$,Q%+1))
  9801.  H%<0 
  9802.  H%>23 
  9803. restore(Fieldnumber%,Fieldnumber%,"hours",94):=
  9804.  M%<0 
  9805.  M%>59 
  9806. restore(Fieldnumber%,Fieldnumber%,"minutes",94):=
  9807.  S%<0 
  9808.  S%>59 
  9809. restore(Fieldnumber%,Fieldnumber%,"seconds",94):=
  9810. !time$=
  9811. time(H%*3600+M%*60+S%)
  9812. text(wi%,ic%)=time$:
  9813. redraw_icon(wi%,ic%)
  9814. seconds(time$)
  9815.  H%,M%,S%,secs%
  9816. (time$)<8 
  9817.   M%=
  9818. (time$)
  9819.   S%=
  9820. time$,2))
  9821.   H%=
  9822. (time$)
  9823.   M%=
  9824. time$,4,2))
  9825.   S%=
  9826. time$,2))
  9827. secs%=H%*3600+M%*60+S%
  9828. =secs%
  9829. time(secs%)
  9830.  time$,hrs$,hrs%,L%,offset%
  9831.  secs%<3600 
  9832.  FullTime% 
  9833. 5  $dateformat%="%MI"+$timesep%+"%SE%TZ"+
  9834. (0):L%=5
  9835. E  $dateformat%="%24"+$timesep%+"%MI"+$timesep%+"%SE%TZ"+
  9836. (0):L%=8
  9837.  "Territory_ReadCurrentTimeZone" 
  9838. ,offset%
  9839.  secs%<3600 
  9840.  offset%=0:
  9841.  Kludge! 
  9842. ,!utctime%=secs%*100-offset%:utctime%?4=0
  9843.  "Territory_ConvertDateAndTime",-1,utctime%,datebuffer%,16,dateformat%
  9844. datebuffer%?11=13
  9845. time$=
  9846. $datebuffer%,L%)
  9847. =time$
  9848. validate(F%,
  9849.  TabFields%,
  9850.  name$)
  9851. selected(prefsW%,21) 
  9852.  row%,field%,Rows%,Rec%,ind%,sind%,pos%,start%,subst%,spos%,date$,subst$,L1%,L2%,L%,S$,exact%,extra$,S%,wi%,ic%,scrcol%,cols%,scroll%
  9853. name$=link$(F%)
  9854. )field%=
  9855. trailing_number(name$,exact%)
  9856. )subst%=
  9857. leading_number(scrcol%,name$)
  9858.  chartype%(F%) 
  9859.  64,65,66,67:
  9860.   S%=
  9861. scroller_number(F%)
  9862.   cols%=scrolldata%(S%,8)
  9863.  "Wimp_GetCaretPosition",,block%
  9864.   wi%=!block%:ic%=block%!4
  9865.  wi%=scrollerW%(S%) 
  9866.  ic% 
  9867.  cols%=scrcol%-1 
  9868.  scroll%=
  9869. :S$=$
  9870. text(wi%,ic%):L%=
  9871. :S$=$Rf%(F%):L%=
  9872. (S$):wi%=mainW%:ic%=field%(F%)
  9873.  S$="" 
  9874.  fix%(F%)<>0 
  9875.  $Rf%(F%)=
  9876. fix_point(S$,F%):
  9877. redraw_icon(wi%,ic%)
  9878.  chartype%(F%)=3 
  9879. check_val(calc$(F%),S$)=
  9880.  chartype%(F%)=5 
  9881. check_date(F%,S$,0,date$)
  9882.  chartype%(F%)=8 
  9883. check_time(S$,wi%,ic%)
  9884.  name$="" 
  9885. name$,1)="#" 
  9886. name$,1)="@" 
  9887. table_number(name$):
  9888.  T%<0 
  9889. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  9890.  S$=field$(F%) 
  9891.  TabFields%=0 
  9892. ,pos%=
  9893. table_field(field%,tabfieldlen%())
  9894.  subst%<0 
  9895.  spos%=pos% 
  9896.  spos%=
  9897. table_field(subst%,tabfieldlen%())
  9898. %start%=SHtabptr%(T%)+offset%-Rec%
  9899. 'ind%=start%+pos%:sind%=start%+spos%
  9900.  exact% 
  9901. 1  cond$="row%>Rows% OR $ind%=S$ OR $sind%=S$"
  9902.  cond$="row%>Rows% OR ($ind%=LEFT$(S$,L1%) AND L1%>0) OR ($sind%=LEFT$(S$,L2%) AND L2%>0)"
  9903.  row%+=1
  9904.   ind%+=Rec%:sind%+=Rec%
  9905.    L1%=
  9906. ($ind%):L2%=
  9907. ($sind%)
  9908. (cond$)=
  9909.  row%>Rows% 
  9910. restore(F%,F%,S$+","+name$,5):=
  9911.  exact% 
  9912. ,    
  9913.  $sind%=
  9914. S$,L2%):extra$=
  9915. S$,L%-L2%)
  9916. +    
  9917.  $ind%=
  9918. S$,L1%):extra$=
  9919. S$,L%-L1%)
  9920. ind%=start%+row%*Rec%
  9921.  I%=0 
  9922.  TabFields%
  9923. ,  rel%(I%)=ind%:ind%+=tabfieldlen%(I%)+1
  9924.  subst%>=0 
  9925.   subst$=$sind%
  9926.   S$=subst$+extra$
  9927.  scroll% 
  9928.  L%=sclen%(S%,scrcol%-1) 
  9929.  L%=len%(F%)
  9930. (S$)<=L% 
  9931. text(wi%,ic%)=S$:
  9932. redraw_icon(wi%,ic%)
  9933.     =row%
  9934. check_val(C$,N$)
  9935.  min$,max$,P%,V,ok%
  9936.     ok%=
  9937.  N$="" 
  9938.  C$<>"" 
  9939.   P%=
  9940. C$,"|")
  9941.  P%>0 
  9942.     min$=
  9943. C$,P%-1)
  9944.     max$=
  9945. C$,P%+1)
  9946. T    
  9947.  min$<>"" 
  9948. (min$) 
  9949.  ok%=
  9950. restore(F%,F%,Tag$(F%)+",(min="+min$+")",58)
  9951. T    
  9952.  max$<>"" 
  9953. (max$) 
  9954.  ok%=
  9955. restore(F%,F%,Tag$(F%)+",(max="+max$+")",59)
  9956. restore(from%,to%,E$,E%)
  9957.  F%,V%,P%,wi%,ic%
  9958.  E%>=0 
  9959. softerror(E$,E%)
  9960.  F%=from% 
  9961.  chartype%(F%) 
  9962. 1    
  9963.  21,27,28,32,34,39,40,45,59:
  9964.  Do nothing
  9965.  64,65,66,67:
  9966.     S%=
  9967. scroller_number(F%)
  9968. *    
  9969.  "Wimp_GetCaretPosition",,block%
  9970.      wi%=!block%:ic%=block%!4
  9971.  wi%=scrollerW%(S%) 
  9972.       $
  9973. text(wi%,ic%)=cell$
  9974.       
  9975. set_caret(0,wi%,ic%)
  9976.       
  9977. redraw_icon(wi%,ic%)
  9978.         
  9979.      
  9980.  field$(F%)<>$Rf%(F%) 
  9981.       $Rf%(F%)=field$(F%)
  9982.       
  9983.  chartype%(F%) 
  9984.         
  9985.  0,1,2,3,4,5,8,63:
  9986. =        
  9987.  from%=to% 
  9988. set_caret(0,mainW%,field%(from%)) 
  9989.         
  9990.  41,42,43:
  9991. X        
  9992.  field$(F%)=" " 
  9993. select(mainW%,field%(F%)) 
  9994. deselect(mainW%,field%(F%))
  9995.         
  9996.  61,62:
  9997. =        V%=
  9998. val(mainW%,field%(F%)):P%=
  9999. $V%,";S"):V%+=P%+1
  10000.         
  10001.  field$(F%) 
  10002.           
  10003. (0):$V%="no"
  10004.           
  10005.  " ":$V%="yes"
  10006. C          
  10007.  chartype%(F%)=61 
  10008.  $V%="null" 
  10009.  $V%="dontcare"
  10010.         
  10011.           
  10012.       
  10013. )      
  10014. redraw_icon(mainW%,field%(F%))
  10015.         
  10016. relations
  10017.  F%,I%,W%,L%,N$,row%,col%,subst%,flags%,name$,x%,y%,vxmin%,vymax%,scrollx%,scrolly%,exact%,scrcol%,width%,height%
  10018. name$=link$(Fieldnumber%)
  10019.  name$="" 
  10020.  $Rf%(Fieldnumber%)="" 
  10021.     F%=-1
  10022. &row%=
  10023. validate(Fieldnumber%,F%,N$)
  10024. 'col%=
  10025. trailing_number(name$,exact%)
  10026. )subst%=
  10027. leading_number(scrcol%,name$)
  10028.  row%>0 
  10029. delete_icons(relateW%,0)
  10030.  I%=0 
  10031. 0      
  10032.  col%:flags%=&00000531+(fcol%(8)<<24)
  10033. #      
  10034.  subst%:flags%=&0B000531
  10035.       
  10036. :flags%=&07000531
  10037.         
  10038. %    L%=
  10039. ($rel%(I%)):
  10040.  L%<5 
  10041.  L%=5
  10042. %    W%=
  10043. string_width($rel%(I%))+8
  10044. P    R%=
  10045. create_icon(0,relateW%,0,-I%*36-36,W%,32,flags%,"",rel%(I%),-1,L%+1)
  10046.  W%>width% 
  10047.  width%=W%
  10048.   $RelTitle%=N$
  10049.   height%=F%*36+36
  10050. #a  !block%=0:block%!4=-height%:block%!8=width%:block%!12=0:
  10051.  "Wimp_SetExtent",relateW%,block%
  10052. $5  !block%=mainW%:
  10053.  "Wimp_GetWindowState",,block%
  10054. %L  vxmin%=block%!4:vymax%=block%!16:scrollx%=block%!20:scrolly%=block%!24
  10055. &Q  !block%=mainW%:block%!4=field%(Fieldnumber%):
  10056.  "Wimp_GetIconState",,block%
  10057. '?  x%=block%!16-scrollx%+vxmin%:y%=block%!20-scrolly%+vymax%
  10058. (7  !block%=relateW%:
  10059.  "Wimp_GetWindowState",,block%
  10060.  ScreenWidth%-x%<width% 
  10061.  width%=ScreenWidth%-x%
  10062. *)  block%!4=x%+4:block%!12=x%+width%-4
  10063. +*  block%!8=y%-height%-4:block%!16=y%-4
  10064. ,/  block%!28=-1:
  10065.  "Wimp_OpenWindow",,block%
  10066.  "Wimp_CreateMenu",,relateW%,x%+4,y%-4
  10067. redraw(relateW%)
  10068. fix_point(F$,F%)
  10069.  F$="" 
  10070.  fix%(F%) 
  10071.  -1:F$=
  10072. (V+0.5)):
  10073.  Integer
  10074.  Floating point. Do nothing
  10075. :@%=&01020009+fix%(F%)*256:F$=
  10076. (V),len%(F%)):@%=&90A
  10077. moveto(key%,P%,D%)
  10078. D%=(D%+1) 
  10079.  filter% 
  10080. @-  P%=
  10081. next_match(P%,D%,Filter$,finished%)
  10082.  finished% 
  10083. B2    matched%+=1:$
  10084. text(filterW%,5)=
  10085. (matched%)
  10086. C     
  10087. redraw_icon(filterW%,5)
  10088.   P%=
  10089. neighbour(key%,P%,D%)
  10090.  P%=top 
  10091.  7:finished%=
  10092. neighbour(key%,P%,D%)
  10093.  merging% 
  10094. merge_next(filter%,key%,P%) 
  10095. display(key%,P%)
  10096. next_match(P%,D%,S$,
  10097.  nomore%)
  10098.  REC%,abort%,passgo%,matched%,base%
  10099. N*dbasehandle%=
  10100. ($database%+".Database")
  10101. base%=SHmarkptr%
  10102.   P%=
  10103. neighbour(key%,P%,D%)
  10104.  P%=top 
  10105.     nomore%=
  10106. T!    P%=
  10107. neighbour(key%,P%,D%)
  10108.     passgo%+=1
  10109. V+    
  10110.  passgo%>1 
  10111.  matched% 
  10112.  abort%=
  10113.  P%=top 
  10114.     matched%=
  10115. Z        
  10116. [     REC%=
  10117. rec_no(k$,key%,P%)
  10118. \'    
  10119. readsmarray(dbasehandle%,REC%)
  10120. ](    
  10121. (S$)=
  10122.  matched%=
  10123. :passgo%=0
  10124.  matched% 
  10125.  abort%
  10126. close_file(dbasehandle%)
  10127.  abort% 
  10128. softerror($Query%,113)
  10129. display(key%,P%)
  10130. e3!block%=mainW%:
  10131.  "Wimp_GetWindowState",,block%
  10132.  template%=1 
  10133.  template%=2 
  10134.  template%=0
  10135.  I%,L%,S%,S$,k$,ok%
  10136.  -1,-2:
  10137. j,  keybase%=SHkeyptr%(0):avail%=!keybase%
  10138. l:    
  10139.  !(keybase%+avail%)>0,template%=2,design%=
  10140. :ok%=
  10141.     incr%=
  10142. ($Increment%)
  10143.  incr%>0 
  10144. p+      
  10145. change_length(RA%+incr%,
  10146. ):ok%=
  10147. q0      keybase%=SHkeyptr%(0):avail%=!keybase%
  10148.       
  10149. softerror("",2)
  10150. s        
  10151.  ok% 
  10152.       
  10153.  design%:
  10154. x0      $RecInfo%="Make adjustments to fields"
  10155. y+      
  10156. read(
  10157. ,fields%,
  10158. ,RA%,$database%)
  10159.       
  10160.  I%=1 
  10161.  fields%
  10162. {I        
  10163.  vtype$(chartype%(I%))="S" 
  10164.  chartype%(I%)<>59 
  10165.  $Rf%(I%)=""
  10166.       
  10167.  I%      
  10168.       
  10169.  template%=2:
  10170. ~S      $RecInfo%="Enter data which you want to appear by default on new records"
  10171. +      
  10172. read(
  10173. ,fields%,
  10174. ,RA%,$database%)
  10175.       
  10176.  P%=-2:
  10177. o      rec%=!(keybase%+avail%+8+KL%(0)+1):$RecInfo%=$Subfile%(file%)+" Record="+
  10178. (rec%)+". (Copy)":key$()=""
  10179.       
  10180.  F%=1 
  10181.  fields%
  10182. )        
  10183.  vtype$(chartype%(F%))="L" 
  10184. 7          L%=
  10185. blob_path(
  10186. ,$database%,REC%,F%,64,b$)
  10187.           
  10188.  L%>0 
  10189. ;            L1%=
  10190. blob_path(
  10191. ,$database%,rec%,F%,64,b1$)
  10192. 7            
  10193.  "OS_CLI","Copy "+b$+" "+b1$+" ~C~V" 
  10194.           
  10195.         
  10196.       
  10197.       REC%=rec%
  10198.       
  10199.  P%=-1:
  10200. d      REC%=!(keybase%+avail%+8+KL%(0)+1):$RecInfo%=$Subfile%(file%)+" Record="+
  10201. (REC%)+". (New)"
  10202. +      
  10203.  printorder$<>"" 
  10204.  F$()=field$()
  10205. +      
  10206. read(
  10207. ,fields%,
  10208. ,RA%,$database%)
  10209. *      
  10210.  printorder$<>"" 
  10211. init_record
  10212.         
  10213. P  $RecInfo%="""Query-by-example"": Enter required values in relevant fields"
  10214. read(
  10215. ,fields%,
  10216. ,RA%,$database%)
  10217.  top:
  10218.  ### Empty subfile accessed ###
  10219. ,  keybase%=SHkeyptr%(0):avail%=!keybase%
  10220. (  REC%=!(keybase%+avail%+8+KL%(0)+1)
  10221. read(
  10222. ,fields%,
  10223. ,RA%,$database%)
  10224.  7:$RecInfo%=$Subfile%(file%)+" Record="+
  10225. (REC%)+". (New)"
  10226.   REC%=
  10227. rec_no(k$,key%,P%)
  10228. read(
  10229. ,fields%,
  10230. ,REC%,$database%)
  10231.   key$(key%)=k$
  10232.   k$=
  10233. stripright(k$,"#")
  10234.   ResKEY$=k$:ResREC%=REC%
  10235. >  $RecInfo%=$Subfile%(file%)+" Record="+
  10236. (REC%)+" Key="+k$
  10237. selected (prefsW%,43) 
  10238.  filemem%(file%,key%)=P%
  10239. text_length(mainW%,starthere%)
  10240.  Access% 
  10241. set_caret(0,mainW%,starthere%)
  10242. identify_field(starthere%)
  10243. redraw(mainW%)
  10244. selected(prefsW%,19) 
  10245. relations
  10246. changed%=
  10247. update_calcs(0)
  10248. *logentry$=$Subfile%(file%)+" "+
  10249. key(0)
  10250.  altered% 
  10251. $RecInfo%)<>"*" 
  10252.  $RecInfo%+=" *"
  10253. base%=SHmarkptr%
  10254. set_icon(markW%,0,(base%?REC%=1))
  10255.  P%=-2 
  10256. softerror("",130)
  10257. ScrollChanged%=
  10258. init_record
  10259.  I%,F%,F$
  10260.  I%=1 
  10261.  printorder$ 
  10262.   F$=
  10263. printorder$,I%,2)
  10264.   F%=
  10265. ("&"+F$)
  10266. is_a_key(F%)<>0 
  10267.  $Rf%(F%)=F$(F%)
  10268.  -------------------- Icon colours -------------------------------
  10269. colour(key%,type%)
  10270.  type%=1 - Selected key,2 - Non-selected key,3 - Not a key
  10271.  J%=0 
  10272.  KF%(key%,J%)>0 
  10273. change_field_cols(key%,type%,J%)
  10274. change_field_cols(key%,type%,fld%)
  10275.  key% 
  10276.  type% 
  10277. )    
  10278.  1:dcol%=fcol%(0):fcol%=fcol%(1)
  10279. )    
  10280.  2:dcol%=fcol%(2):fcol%=fcol%(3)
  10281.  type% 
  10282. )    
  10283.  1:dcol%=fcol%(4):fcol%=fcol%(5)
  10284. )    
  10285.  2:dcol%=fcol%(6):fcol%=fcol%(7)
  10286.  3:dcol%=&17:fcol%=&07
  10287. set_icon_cols(mainW%,desc%(KF%(key%,fld%)),dcol%)
  10288. 6col%=
  10289. get_icon_cols(mainW%,field%(KF%(key%,fld%)))
  10290.  (col% 
  10291.  16)=(fcol%(8) 
  10292.  16) 
  10293.  fcol%=(fcol% 
  10294.  &F0) 
  10295.  (col% 
  10296. set_icon_cols(mainW%,field%(KF%(key%,fld%)),fcol%)
  10297. get_icon_cols(wi%,ic%)
  10298. ;!block%=wi%:block%!4=ic%:
  10299.  "Wimp_GetIconState",,block%
  10300. =block%?27
  10301. set_icon_cols(wi%,ic%,col%)
  10302.  col%<0 
  10303.  col%=
  10304. (col%):block%!12=&0F000000 
  10305.  block%!12=&FF000000
  10306. 0!block%=wi%:block%!4=ic%:block%!8=(col%<<24)
  10307.  "Wimp_SetIconState",,block%
  10308. read_colours(f$)
  10309.  F,I%
  10310. fcol%()=7
  10311. #F,fcol%(I%)
  10312. set_icon_cols(colW%,I%,fcol%(I%))
  10313.   I%+=1
  10314. close_file(F)
  10315.  I%=0 
  10316.  Keys%
  10317. colour(I%,2)
  10318. colour(key%,1)
  10319.  I%=1 
  10320.  fields%
  10321.  link$(I%)<>"" 
  10322. set_icon_cols(mainW%,field%(I%),fcol%(8))
  10323.  mandatory%?I%=1 
  10324. set_icon_cols(mainW%,field%(I%),fcol%(9))
  10325. write_colours(f$)
  10326.  F,I%
  10327.  I%=0 
  10328. #F,fcol%(I%)
  10329. close_file(F)
  10330. find(S$,key%,disp%)
  10331.  P%,F%,H%,recnum%,abort%,cond$
  10332.  case%(key%) 
  10333. u(S$)
  10334. S$,1)="#" 
  10335.   REC%=
  10336. S$,2))
  10337.  REC%>=0 
  10338.  REC%<RA% 
  10339. *    
  10340. read(
  10341. ,fields%,
  10342. ,REC%,$database%)
  10343. $    S$=key$(key%):H%=1:recnum%=
  10344.     1    
  10345. select(searchW%,6):
  10346. deselect(searchW%,5)
  10347. $    
  10348. softerror(S$,56):abort%=
  10349. S$,KL%(key%))
  10350.  abort% 
  10351. =addr
  10352. val$=
  10353. type(key%)
  10354.  val$="VAL" 
  10355.  kl%=KL%(key%) 
  10356.  kl%=
  10357. search(S$,key%,1+H%)
  10358.  P%<0 
  10359. selected(searchW%,6) 
  10360.   F%=file%
  10361.     file%=(file%+1) 
  10362.     top=8*file%+LH%
  10363.      P%=
  10364. search(S$,key%,1+H%)
  10365.  P%>0 
  10366.  file%=F%
  10367.  P%>0 
  10368. set_subfile(file%)
  10369.  val$="VAL" 
  10370.  cond$="VAL($(SHkeyptr%(key%)+P%+8))=VAL(S$)" 
  10371.  cond$="LEFT$($(SHkeyptr%(key%)+P%+8),kl%)=S$"
  10372. matches%=0
  10373.  P%>=0 
  10374.  recnum%:RecF%=
  10375. :addr=P%:matches%=1
  10376.  P%>=0:RecF%=
  10377.  ### RecF% is used only by !DELETE in script language ###
  10378.  1  matches%=
  10379. count_matches("first",cond$,addr)
  10380. selected(searchW%,6) 
  10381. "$    F%=file%:file%=(file%+1) 
  10382. #        
  10383.       top=8*file%+LH%
  10384.       P%=
  10385. search(S$,key%,1)
  10386. &=      
  10387.  P%>0 
  10388.  matches%+=
  10389. count_matches("first",cond$,Q%)
  10390.       file%=(file%+1) 
  10391.  file%=F%
  10392.     top=8*file%+LH%
  10393.  recnum%:
  10394. softerror("#"+
  10395. (REC%),55)
  10396.  disp% 
  10397.  addr=
  10398. (P%):flash%=KF%(key%,0):state%=
  10399. selected(mainW%,field%(flash%)) 
  10400.  addr=P%
  10401. text(searchW%,7)=
  10402. (matches%)+" found":
  10403. redraw_icon(searchW%,7)
  10404.  merging%:
  10405. merge_next(filter%,key%,addr)
  10406.  disp%:
  10407. display(key%,addr)
  10408. 3    =addr
  10409. count_matches(end$,c$,
  10410.  ### Scan back to FIRST match ###
  10411.   P%=
  10412. neighbour(key%,P%,0)
  10413.  ### ...and point at it ###
  10414. neighbour(key%,P%,1)
  10415.  end$="first" 
  10416.  Q%=P%
  10417.  ### Then scan to last match ###
  10418.   N%+=1
  10419.   P%=
  10420. neighbour(key%,P%,1)
  10421.  ### ...and point at it ###
  10422. neighbour(key%,P%,0)
  10423.  end$="last" 
  10424.  Q%=P%
  10425. lookup(F%)
  10426.  K$,S%,P%,Q%,pos%
  10427. check_record 
  10428. S%=Rf%(F%)
  10429. ($S%)
  10430.  $S%<>"" 
  10431.  chartype%(F%)<9 
  10432.  "Wimp_GetCaretPosition",,block%
  10433.   pos%=block%!20:Q%=pos%
  10434.  Q%<L% 
  10435.  S%?Q%<>44
  10436.     Q%+=1
  10437.   Q%+=1
  10438.  pos%=0 
  10439.  P%=1 
  10440.  P%=pos%-1 
  10441.  P%>0 
  10442.  S%?P%<>44
  10443.     P%-=1
  10444.  P%=0 
  10445.  P%=1 
  10446.  P%+=2
  10447.   K$=
  10448. $S%,P%,Q%-P%)
  10449.   addr=
  10450. find(K$,key%,
  10451. get_it_in(filename$)
  10452.  "Hourglass_On"
  10453.  "OS_File",5,filename$ 
  10454.  d%,,ftype%
  10455. a9ftype%=(ftype%>>8) 
  10456.  &fff:wi%=block%!20:ic%=block%!24
  10457. b!Scroller%=
  10458. scroller_num2(wi%)
  10459. field%=(ic%+1) 
  10460.  wi%=mainW% 
  10461.  chartype%(field%) 
  10462. fP    
  10463.  d%<>2 
  10464. transfer_blob(wi%,ic%,filename$,d%,ftype%):d%=0:ftype%=0
  10465. gF    
  10466. transfer_blob(wi%,ic%,filename$,d%,ftype%):d%=0:ftype%=0
  10467. h-    
  10468.  Stop later lines from grabbing file
  10469.  d%=2 
  10470.  wi% 
  10471.  reformW%:
  10472. n-    
  10473.  "OS_File",5,filename$+".Form" 
  10474.  d%=1 
  10475. p+      $Newform%="":
  10476. redraw_icon(wi%,12)
  10477. qI      $Reformatted%=filename$:
  10478. set_caret(0,wi%,6):
  10479. redraw_icon(wi%,6)
  10480. r)      
  10481. shade(wi%,0,
  10482. shade(wi%,2,
  10483.       
  10484. softerror("",28)
  10485. t        
  10486.  mergebaseW%:
  10487. v3    $
  10488. text(wi%,3)=filename$:
  10489. redraw_icon(wi%,3)
  10490. w7    
  10491. shade(wi%,4,
  10492. shade(wi%,7,
  10493. shade(wi%,1,
  10494. set_caret(0,wi%,4)
  10495. z!    
  10496. leaf(filename$),1) 
  10497.       
  10498.  "!":
  10499. |1      
  10500.  ### Is it an Impression document? ###
  10501. }3      
  10502.  "OS_File",5,filename$+".!DocData" 
  10503.       
  10504.  d%=1 
  10505. "        
  10506. ready_to_merge(&2000)
  10507.         
  10508. 4        
  10509.  ### Is it a Powerbase application? ###
  10510. ;        
  10511.  "OS_File",5,filename$+".Indices" 
  10512.  d%,,type%
  10513. U        
  10514.  d%=2 
  10515.  "OS_CLI","Rename "+filename$+".Indices "+filename$+".Indexes"
  10516. C        
  10517.  "OS_File",5,filename$+".Indexes" 
  10518.  d%,,type%        
  10519. $        
  10520.  d%=2 
  10521. check_record 
  10522. .          
  10523.  present%>0 
  10524.  design%=
  10525. $          leaf$=
  10526. leaf(filename$)
  10527. -          $Title%=
  10528. leaf$,2,NameLength%-1)
  10529. 1          
  10530. open_files(filename$):SaveCount%=0
  10531.         
  10532.       
  10533.       
  10534. 5      
  10535.  ### It's an ordinary directory folder ###
  10536. 1      
  10537. transfer_blob(wi%,ic%,filename$,d%,-1)
  10538.         
  10539.  ftype% 
  10540. ;    
  10541.  &7f1:
  10542. load_table(filename$,
  10543. display(key%,addr)
  10544. z    
  10545.  &7f2:
  10546.  wi%=reformW% 
  10547. leaf(filename$)="Form" 
  10548. $Reformatted%,".")=0 
  10549.  $Newform%=filename$:
  10550. redraw_icon(wi%,12)
  10551. )    
  10552.  &7f3:
  10553. load_selection(filename$)
  10554. -    
  10555.  &7f4:
  10556. load_query(filename$,wi%,ic%)
  10557. 8    
  10558.  &7f5:
  10559. get_options(printW%,printerW%,filename$)
  10560. B    
  10561.  &dfe:$
  10562. text(csvW%,13)=filename$:
  10563. start_import("CSV",wi%)
  10564. ?    
  10565.  &ff9,&aff:
  10566. transfer_blob(wi%,ic%,filename$,d%,ftype%)
  10567. +    
  10568.  &bc5,&b27:
  10569. ready_to_merge(ftype%)
  10570.  &fff:
  10571. 1    F=
  10572. (filename$):header$=
  10573. close_file(F)
  10574.  wi% 
  10575.       
  10576.  mainW%:
  10577.        
  10578.  chartype%(field%) 
  10579. ?        
  10580.  36,39:
  10581. transfer_blob(wi%,ic%,filename$,d%,ftype%)
  10582.         
  10583. 2        
  10584. header$,7)="!SCRIPT" 
  10585.  present%=7 
  10586. (          
  10587. execute_script(filename$)
  10588. D          
  10589. text(csvW%,13)=filename$:
  10590. start_import("text",wi%)
  10591.         
  10592.       
  10593. "      
  10594.  scrollerW%(Scroller%):
  10595. #      
  10596. header$,7)="!SCRIPT" 
  10597. &        
  10598. execute_script(filename$)
  10599. C        
  10600. import_to_scroller(Scroller%,filename$):
  10601. asterisk(
  10602.       
  10603. %      
  10604.  tableW%(Tablenumber%),-2:
  10605. >      $
  10606. text(csvW%,13)=filename$:
  10607. start_import("text",wi%)
  10608. :      
  10609.  customise% 
  10610. (libfunc$+"_drop(wi%,ic%)")
  10611.         
  10612.  "Hourglass_Off"
  10613. ready_to_merge(doctype%)
  10614. selected(passW%,13) 
  10615.  present%=7 
  10616.  doctype% 
  10617. A    
  10618.  &bc5:$ImpulseApp%="Impression":$mergewith%=$ImpulseApp%
  10619. A    
  10620.  &b27:$ImpulseApp%="OvationPro":$mergewith%=$ImpulseApp%
  10621. redraw_icon(mergeW%,9)
  10622.    document$=
  10623. leaf(filename$)
  10624. document$,1)="!" 
  10625.  document$=
  10626. document$,2)
  10627.  "OS_CLI","Filer_Run "+filename$
  10628.   Impulse_wait%=
  10629. softerror("",107)
  10630. open_files(f$)
  10631.  I%,J%,F%,A$
  10632.  ### Delete redundant files if present ###
  10633.  "OS_CLI","Remove "+f$+".Winsize"
  10634.  "OS_CLI","Remove "+f$+".Choices"
  10635. read_sys_vars(f$)
  10636. leaf$=
  10637. leaf(f$)
  10638.  "OS_File",5,f$+".Config" 
  10639.  d%=1 
  10640. get_configuration(f$+".Config","local")
  10641. #$Title%=
  10642. leaf$,2,NameLength%-1)
  10643.  "OS_File",5,f$+".Database" 
  10644.  d%,,type%
  10645.  d%=1 
  10646.  present%=present% 
  10647. type%=(type%>>8) 
  10648.  &fff
  10649.  type%=&7f2 
  10650. M  dbtype$="old":$Util1%="Adjust format...":$Util2%="New record format..."
  10651.  dbtype$="new":$Util1%="Alter format...":$Util2%="Rebuild database..."
  10652.  "OS_File",5,f$+".PrimaryKey" 
  10653.  d%=1 
  10654.  present%=present% 
  10655.  "OS_File",5,f$+".Form" 
  10656.  d%=1 
  10657.  present%=present% 
  10658. 9SHlogoptr%=
  10659. extend_named_sliding_block(logoanchor%,8)
  10660.  "OS_File",5,f$+".UsrSprites" 
  10661.  d%,,,,len%
  10662.  d%=1 
  10663. @  SHlogoptr%=
  10664. extend_named_sliding_block(logoanchor%,len%+8)
  10665.   !SHlogoptr%=len%+4
  10666.  "OS_File",255,f$+".UsrSprites",SHlogoptr%+4
  10667.   logosloaded%=
  10668.  "OS_File",5,f$+".Title" 
  10669.  d%,,,,len%
  10670.  d%=1 
  10671. B  SHtitleptr%=
  10672. extend_named_sliding_block(titleanchor%,len%+8)
  10673.  "OS_File",255,f$+".Title",SHtitleptr%+4
  10674.   !SHtitleptr%=len%+4
  10675.   HasTitle%=1
  10676.  HasTitle%=0
  10677. $database%=f$
  10678.  "OS_CLI","Set Dbase$Dir "+f$
  10679.  present% 
  10680.  0,1,5:Access%=
  10681. :Modify%=
  10682. resume_opening
  10683. access(f$,accessW%) 
  10684. resume_opening
  10685. wimp_error(
  10686. ,254,0,
  10687. msg("Err24"))
  10688. read_sys_vars(f$)
  10689.  E%,F,A$,L$,S$
  10690. (f$+".!Run")
  10691.   S$=
  10692. S$,"Acl$Dir")>0 
  10693.  A$=S$
  10694. S$,"Log$Dir")>0 
  10695.  L$=S$
  10696. close_file(F)
  10697.  A$="" 
  10698.  A$="Set Acl$Dir "+f$
  10699.  L$="" 
  10700.  L$="Set Log$Dir "+f$
  10701.  "XOS_ReadVarVal","Acl$Dir",,-1 
  10702.  ,,E%:
  10703.  E%=0 
  10704.  "OS_CLI",A$
  10705.  "XOS_ReadVarVal","Log$Dir",,-1 
  10706.  ,,E%:
  10707.  E%=0 
  10708.  "OS_CLI",L$
  10709. access(f$,wi%)
  10710.  F,I%,L%,P%,col%,last%,keybase%,login%,attempts%,old%,file$
  10711. 'file$=f$+".Cols":last%=8:F=
  10712. (file$)
  10713.  F=0 
  10714.  file$=f$+".Colours":last%=6:F=
  10715. (file$)
  10716.  F>0 
  10717.   old%=
  10718.  I%=0 
  10719.  last%
  10720.     ,    
  10721.  last%=6 
  10722. #F,col% 
  10723. #F,fcol%(I%)
  10724. write_colours(f$+".FieldCols")
  10725. (f$+".Data")
  10726.  F=0 
  10727.  fatal_err%,
  10728. msg("Err18,"+f$+".Data")
  10729. #F,S$:$Read%=
  10730. encrypt(S$,
  10731. #F,S$:$Write%=
  10732. encrypt(S$,
  10733. #F,S$:$Manager%=
  10734. encrypt(S$,
  10735.   I%+=1
  10736. #F,Z%
  10737. set_icon(passW%,I%+8,Z%)
  10738. close_file(F)
  10739. "ShowTools%=
  10740. selected(passW%,9)
  10741.  old% 
  10742. passwords(0,passW%,4,4):
  10743.  "OS_CLI","Remove "+file$
  10744.  "OS_File",5,"<Acl$Dir>.Acl" 
  10745.  d%:acl%=(d%=1)
  10746.  $Manager%="" 
  10747.  acl%=
  10748.  Access%=
  10749. :Modify%=
  10750. 9$AccessTitle%="!Powerbase opening "+
  10751. leaf($database%)
  10752.  acl% 
  10753. position_window(wi%,0,0,0,310,0,110):refuse$="Access denied"
  10754. position_window(wi%,0,0,0,200,0,0):refuse$="Password not known"
  10755.  "Hourglass_Smash"
  10756. $0!block%=wi%:
  10757.  "Wimp_GetWindowState",,block%
  10758.  block%!4,block%!8,block%!12-block%!4,block%!16-block%!8
  10759. '(  cancel%=
  10760. :login%=
  10761. :accessbutton%=0
  10762.   $Password%="":$UserID%=""
  10763. redraw_icon(wi%,1):
  10764. redraw_icon(wi%,0)
  10765. *+  $
  10766. text(wi%,5)="Type in your password"
  10767.  acl% 
  10768. set_caret(0,wi%,0) 
  10769. set_caret(0,wi%,1)
  10770. poll(
  10771.  accessbutton%>0
  10772.  accessbutton% 
  10773.  2:cancel%=
  10774. 2+    password$=$Password%:user$=$UserID%
  10775.  acl% 
  10776.       F=
  10777. ("<Acl$Dir>.Acl")
  10778.       
  10779. 6!        
  10780. #F,id$,personal$,pw%
  10781. 7X        
  10782.  id$=
  10783. encrypt(user$,
  10784.  personal$=
  10785. encrypt(password$,
  10786.  pw%>0 
  10787.  login%=
  10788.       
  10789.  login% 
  10790.       
  10791. close_file(F)
  10792.       
  10793.       user$="<none>"
  10794.       
  10795.  password$ 
  10796. =&        
  10797.  $Manager%:pw%=3:login%=
  10798. >$        
  10799.  $Write%:pw%=2:login%=
  10800. ?#        
  10801.  $Read%:pw%=1:login%=
  10802.       
  10803. A        
  10804.  (login% 
  10805.  cancel%) 
  10806.     $
  10807. text(wi%,5)=refuse$
  10808. F!    
  10809. set_icon_cols(wi%,5,&1B)
  10810.     delay%=
  10811. H        
  10812.       
  10813. poll(
  10814. >delay%
  10815. K!    
  10816. set_icon_cols(wi%,5,&17)
  10817.     attempts%+=1
  10818. MR    att$(attempts%)=
  10819. (attempts%)+","+
  10820. leaf($database%)+","+user$+","+password$
  10821.  login% 
  10822.  cancel% 
  10823.  attempts%=3
  10824. P#Access%=(pw%>1):Modify%=(pw%>2)
  10825. close_window(wi%)
  10826.  0,0,ScreenWidth%,ScreenHeight%
  10827.  attempts%=3 
  10828. T"  user$="<unrecognised>":pw%=0
  10829. open_log("<Log$Dir>.Log",
  10830.  Even if logging not normally enabled Powerbase will log any
  10831.  three-times failed attempt to open password-protected database.
  10832.  I%=1 
  10833. Y2    
  10834. write_log(-1,
  10835. msg("Err122,"+att$(I%)),"")
  10836. close_log("<Log$Dir>.Log")
  10837. close_down
  10838. =login%
  10839. resume_opening
  10840.  "Hourglass_On"
  10841. selected(passW%,16) 
  10842. open_log("<Log$Dir>.Log",
  10843. ($database%+".Subfiles")
  10844.  I%=0 
  10845. f*    
  10846.  0:$Subfile%(I%)="Subfile "+
  10847.     S$=
  10848. i%    
  10849.  S$="" 
  10850.  S$="Subfile "+
  10851.     $Subfile%(I%)=S$
  10852. close_file(F)
  10853. load_user_functions(f$)
  10854.  "OS_File",5,f$+".FieldCols" 
  10855.  d%=1 
  10856. read_colours($database%+".FieldCols")
  10857.  "OS_File",5,f$+".PrintRes.!PrintOpts" 
  10858.  d%=1 
  10859. get_options(printW%,printerW%,f$+".PrintRes.!PrintOpts")
  10860.  "OS_File",5,f$+".Preference" 
  10861.  d%=1 
  10862. get_preferences(prefsW%,f$+".Preference")
  10863.  "OS_File",5,f$+".CSVoptions" 
  10864.  d%=1 
  10865. get_csv_options(f$+".CSVoptions")
  10866. deselect(prefsW%,36):
  10867. select(prefsW%,35):
  10868. shade(prefsW%,35,
  10869. f$,3)="RAM" 
  10870.  ram%=
  10871. tick(markM%,0,
  10872. shade(csvW%,18,Modify%)
  10873. shade(csvW%,21,Access%)
  10874. shade(printW%,31,Modify%)
  10875. shade(printW%,34,Access%)
  10876. shade(prefsW%,36,Modify%)
  10877. shade(prefsW%,38,Access%)
  10878. shade(prefsW%,45,
  10879. lit(iconbarM%,1,
  10880. lit(iconbarM%,2,Modify%)
  10881. lit(iconbarM%,3,
  10882. lit(iconbarM%,4,Modify%)
  10883. lit(mainM%,6,ShowTools% 
  10884.  (Tools%=1))
  10885. lit(miscM%,0,Access%)
  10886. lit(miscM%,1,Modify%)
  10887. lit(miscM%,2,Access%)
  10888. lit(miscM%,3,Access%)
  10889. lit(miscM%,4,Access%)
  10890. lit(miscM%,5,Access%)
  10891. lit(validateM%,0,Access%)
  10892. lit(fieldM%,0,Access%)
  10893. lit(fieldM%,2,Access%)
  10894. lit(fieldM%,3,Access%)
  10895. lit(tableM%,0,Access%)
  10896. lit(tableM%,3,Access%)
  10897. lit(designM%,2,((present% 
  10898.  4)=0))
  10899.  I%=0 
  10900. lit(utilityM%,I%,(present%=7))
  10901.  present%<4 
  10902.  design%=
  10903. :markpane%=
  10904. lit(designM%,7,
  10905. fields%=
  10906. get_form(Fptr%)
  10907. Lchartype%(0)=100:chartype%(MaxFields%+1)=100:chartype%(MaxFields%+2)=100
  10908.  fields%>0 
  10909.   starthere%=
  10910. start_at
  10911. "  Lastwritable%=
  10912. last_writable
  10913. $  fieldsM%=
  10914. field_menu(items%,1)
  10915.  $Reformatted%="" 
  10916.  adjust% 
  10917. lit(designM%,3,(fields%>0))
  10918.  present% 
  10919.   $RecInfo%=
  10920. msg("Err156")
  10921.  I%=1 
  10922. lit(designM%,I%,
  10923. lit(designM%,6,
  10924. get_winpos
  10925.  SHformptr%=0 
  10926. D    SHformptr%=
  10927. extend_named_sliding_block(formanchor%,SHclaim%)
  10928.     Fptr%=SHformptr%
  10929.      fields%=0:Fieldnumber%=0
  10930.  $Reformatted%="" 
  10931.  $RecInfo%=
  10932. msg("Err157") 
  10933.  $RecInfo%=
  10934. msg("Err159")
  10935. first_writable>0 
  10936. lit(designM%,4,
  10937. lit(designM%,5,
  10938. get_winpos
  10939.   $RecInfo%=
  10940. msg("Err158")
  10941.  "OS_File",5,$database%+".Database" 
  10942.  ,,,,len%
  10943. -  RA%=(len% 
  10944.  Length%)-1:$Records%=
  10945. (RA%)
  10946. first_writable>0 
  10947. get_winpos
  10948. lit(utilityM%,0,
  10949. complete(4)
  10950. softerror("",203)
  10951. shade(prefsW%,45,
  10952. lit(mainM%,8,
  10953. selected(passW%,13))
  10954. lit(mainM%,9,
  10955. selected(passW%,13))
  10956. lit(mainM%,10,
  10957. selected(passW%,13))
  10958. lit(mainM%,2,
  10959. selected(passW%,14))
  10960.  "OS_File",5,$database%+".Database" 
  10961.  ,,,,len%
  10962.   RA%=(len% 
  10963.  Length%)-1
  10964.   $Records%=
  10965. (RA%)
  10966.  (len% 
  10967.  Length%)<>0 
  10968. rectify
  10969. @  SHmarkptr%=
  10970. extend_named_sliding_block(markanchor%,RA%+20)
  10971. clear_marks(RA%)
  10972. load_index($database%+".PrimaryKey",0,
  10973. (  key%=0:file%=0:
  10974. set_subfile(file%)
  10975. #  $Subfilename%=$Subfile%(key%)
  10976. set_keydata(key%)
  10977. X  keybase%=SHkeyptr%(0):
  10978.  keybase%!4>0 
  10979.  $Increment%=
  10980. (keybase%!4) 
  10981.  $Increment%="0"
  10982. load_indexes
  10983. get_tables
  10984. load_marks
  10985. count(key%,RU%):
  10986. update_stats
  10987. get_winpos
  10988. load_calcs
  10989. auto_csv(
  10990. selected(prefsW%,44))
  10991. limit_actions(Access%,
  10992.   addr=
  10993. moveto(key%,top,1)
  10994.  "Hourglass_Off"
  10995. iconbar_icon($Title%)
  10996. Apath$=$database%+".Customise.":name$=$Title%:lib$=path$+name$
  10997.  "OS_File",5,lib$ 
  10998.  d%,,,,len%
  10999.  d%=0 
  11000.  name$="Demo":lib$=path$+name$:
  11001.  "OS_File",5,lib$ 
  11002.  d%,,,,len%
  11003.  d%=0 
  11004. 0  path$=PbaseDir$+"."+program$+".Customise."
  11005. G  name$=progname$:lib$=path$+name$:
  11006.  "OS_File",5,lib$ 
  11007.  d%,,,,len%
  11008.  d%=0 
  11009.  name$="Demo":lib$=path$+name$:
  11010.  "OS_File",5,lib$ 
  11011.  d%,,,,len%
  11012. delete_icons(keypadW%,29):toolheight%=770:padheight%=316
  11013.  d%=1 
  11014.   libfunc$="FN_"+name$
  11015.   N%=-1
  11016.  N%+=1
  11017.  lib$(N%)=lib$ 
  11018.  N%=NextLib%
  11019. loadable 
  11020. =    lib%(N%)=
  11021.  Flag used libraries to avoid memory leak
  11022.  library$ 
  11023.       
  11024.  lib$:new%=
  11025.        
  11026. :library$=lib$:new%=
  11027.         
  11028.  Tools% 
  11029. .      
  11030.  1:xm%=600:ym%=-208:xw%=12:yw%=-208
  11031. -      
  11032.  2:xm%=92:ym%=-816:xw%=12:yw%=-816
  11033.         
  11034. J    customise%=
  11035. (libfunc$+"_setup(LEFT$(path$),xm%,ym%,xw%,yw%,new%)")
  11036.  Tools%=2 
  11037. open_window(mainW%)
  11038. exit%=
  11039.  special%(0) 
  11040. (libfunc$+"_function(0)")
  11041. loadable
  11042.     ok%=
  11043.  N%=MaxLibs%:
  11044. softerror("",236):ok%=
  11045.  N%=NextLib%:
  11046. unique(lib$,N%+1) 
  11047. O    
  11048.  name$<>"Demo" 
  11049. dir($database%)<>CustDir$ 
  11050. softerror(CustDir$,134)
  11051. #    lib$(N%)=lib$:NextLib%+=1  
  11052. 1    
  11053.  len%>MaxSize% 
  11054.  MaxSize%=len%:
  11055.  lib$()
  11056. clear_marks(N%)
  11057.  I%=0 
  11058.   SHmarkptr%!I%=0
  11059. deselect(markW%,0)
  11060. shade(markW%,1,
  11061. MarkedRecs%=0
  11062. tick(markM%,0,
  11063. tick(markM%,1,
  11064. val(markW%,0)="Snull,yes"
  11065. save_marks
  11066. selected(prefsW%,48) 
  11067.   f$=$database%+".Marks"
  11068.  MarkedRecs%>0 
  11069. C    
  11070. ticked(markM%,1) 
  11071.  SHmarkptr%?RA%=255 
  11072.  SHmarkptr%?RA%=1
  11073. &    SHmarkptr%!(RA%+1)=MarkedRecs%
  11074. 2    
  11075. save(f$,&ffd,SHmarkptr%,SHmarkptr%+RA%+5)
  11076. "    
  11077.  "OS_CLI","Remove "+f$
  11078. load_marks
  11079.  d%,f$
  11080. selected(prefsW%,48) 
  11081.   f$=$database%+".Marks"
  11082.  "OS_File",5,f$ 
  11083.  d%=1 
  11084.  '&    
  11085.  "OS_File",255,f$,SHmarkptr%
  11086.  (&    MarkedRecs%=SHmarkptr%!(RA%+1)
  11087.  )(    
  11088. tick(markM%,0,SHmarkptr%?RA%=1)
  11089.  **    
  11090. tick(markM%,1,SHmarkptr%?RA%=255)
  11091. warn_of_marks
  11092. rectify
  11093.  REC%,I%,J%,F$
  11094. REC%=-1
  11095.  3*dbasehandle%=
  11096. ($database%+".Database")
  11097.  REC%<RA% 
  11098. (F$)<>0
  11099.   REC%+=1
  11100.  6!  
  11101. #dbasehandle%=Length%*REC%
  11102.   F$=
  11103. #dbasehandle%
  11104. (F$)=0 
  11105. softerror("",109)
  11106.  ;!  
  11107. #dbasehandle%=REC%*Length%
  11108.  "Hourglass_On"
  11109.  I%=REC% 
  11110.  >!    
  11111. #dbasehandle%=I%*Length%
  11112.  J%=1 
  11113.  fields%
  11114.       
  11115. #dbasehandle%,""
  11116.  B>    
  11117.  "Hourglass_Percentage",((I%-REC%)*100) 
  11118.  (RA%-REC%)
  11119.  "Hourglass_Off"
  11120.  RA%+=1
  11121. #dbasehandle%=(RA%+1)*Length%
  11122. close_file(dbasehandle%)
  11123. get_configuration(f$,z$)
  11124.  F,S$,C$,P%
  11125.   S$=
  11126. S$,1)<>"|" 
  11127.  Q+  P%=
  11128. S$," "):C$=
  11129. S$,P%+1):S$=
  11130. S$,P%-1)
  11131.   C$=
  11132. stripright(C$," ")
  11133.       
  11134.  "Fields":
  11135.  U(      
  11136.  z$="main" 
  11137.  MaxFields%=
  11138.  V>      
  11139.  MaxFields%>127 
  11140. close_file(F):
  11141. msg("Err185")
  11142.  W/      
  11143.  "Keys":
  11144.  z$="main" 
  11145.  MaxKeys%=
  11146.  X/      
  11147.  "Tabs":
  11148.  z$="main" 
  11149.  MaxTabs%=
  11150.  Y1      
  11151.  "Cols":
  11152.  z$="main" 
  11153.  MaxCols%=
  11154. (C$)-1
  11155.  Z3      
  11156.  "Scrolls":
  11157.  z$="main" 
  11158.  MaxLists%=
  11159.  [2      
  11160.  "MaxLibs":
  11161.  z$="main" 
  11162.  MaxLibs%=
  11163.  \/      
  11164.  "CustDir":
  11165.  z$="main" 
  11166.  CustDir$=C$
  11167.  ]-      
  11168.  C$="Default" 
  11169.  CustDir$=PbaseDir$
  11170.  ^7      
  11171.  "BTime":
  11172.  z$="main" 
  11173.  Bannertime%=
  11174. (C$)*100
  11175.  _9      
  11176.  "LeftOpen":
  11177.  z$="main" 
  11178.  leftmenu%=(C$="YES")
  11179.  `.      
  11180.  "Tools":
  11181.  z$="main" 
  11182.  Tools%=
  11183.  a$      
  11184.  "BackGnd":winback%=
  11185.  b"      
  11186.  "Upper":uc%=(C$="YES")
  11187.  c!      
  11188.  "DirOpts":dirdisp$=C$
  11189.  d"      
  11190.  "ExtFiles":objname$=C$
  11191.  e#      
  11192.  "Query":QBE%=(C$="QBE")
  11193.  f_      
  11194.  "PathLen":RLmax%=
  11195. (C$):
  11196. C$)="A" 
  11197.  Remotepath$="Absolute" 
  11198.  Remotepath$="Relative"
  11199.  g,      
  11200.  "FontAdj":FontAdjust%=(C$="YES")
  11201.  h)      
  11202.  "Multi":multitask%=(C$="YES")
  11203.  i+      
  11204.  "MarkPane":markpane%=(C$="YES")
  11205.  j'      
  11206.  "NameLen":NameLength%=
  11207.  k@      
  11208.  "ButtonAtts":Buttonwidth%=
  11209. (C$):WithLeaf%=(
  11210. C$)="L")
  11211.  l,      
  11212.  "DialDelay":DialDelay%=
  11213. (C$)*100
  11214.  m)      
  11215.  "TimeFirst":TimeFirst$=
  11216. C$,1)
  11217.  n+      
  11218.  "FullTime":FullTime%=(C$="YES")
  11219.  o*      
  11220.  "CentChange":CentChange%=
  11221.  p"      
  11222.  "Output":Output%=
  11223.  q        
  11224. close_file(F)
  11225. get_options(wi%,wi2%,f$)
  11226.  F,S$,C$,P%
  11227. f$,20)="Resources.!PrintOpts" 
  11228.  prtopts$="" 
  11229.  prtopts$=f$
  11230.   S$=
  11231. S$,1)<>"|" 
  11232.     P%=
  11233. S$," ")
  11234. 2    
  11235.  P%>0 
  11236. S$,P%+1):S$=
  11237. S$,P%-1) 
  11238.  C$=""
  11239.       
  11240.  "Destination":
  11241. -      
  11242. deselect(wi%,
  11243. selected_esg(wi%,4))
  11244.       
  11245.         
  11246.  "window":ic%=22
  11247.         
  11248.  "file":ic%=23
  11249.         
  11250.  "printer":ic%=25
  11251.       
  11252.       
  11253. select(wi%,ic%)
  11254.       
  11255. set_dest_sprite
  11256.       
  11257.  "Headings":
  11258. -      
  11259. deselect(wi%,
  11260. selected_esg(wi%,1))
  11261.       
  11262. )        
  11263.  "descriptor":
  11264. select(wi%,2)
  11265. "        
  11266.  "tag":
  11267. select(wi%,1)
  11268. %        
  11269.  "none":
  11270. select(wi%,36) 
  11271.       
  11272.       
  11273.  "Format":
  11274. -      
  11275. deselect(wi%,
  11276. selected_esg(wi%,3))
  11277. /      
  11278. deselect(wi2%,
  11279. selected_esg(wi2%,2))
  11280.       
  11281. C$,5) 
  11282. %        
  11283.  "horiz":
  11284. select(wi%,15)
  11285. $        
  11286.  "vert":
  11287. select(wi%,16)
  11288. %        
  11289.  "table":
  11290. select(wi2%,7)
  11291. %        
  11292.  "label":
  11293. select(wi2%,8)
  11294.       
  11295.       
  11296.  "Scroller":
  11297. -      
  11298. deselect(wi%,
  11299. selected_esg(wi%,6))
  11300.       
  11301. *        
  11302.  "Single row":
  11303. select(wi%,40)
  11304. '        
  11305.  "Columns":
  11306. select(wi%,41)
  11307.       
  11308. '      
  11309.  "CellSep":$
  11310. text(wi%,50)=C$
  11311. '      
  11312.  "RowTerm":$
  11313. text(wi%,51)=C$
  11314.       
  11315.  "ShrinkRow":
  11316. %      
  11317. set_icon(wi%,43,(C$="ON"))
  11318. *      
  11319. shade(wi%,43,
  11320. selected(wi%,40))
  11321. *      
  11322. shade(wi%,51,
  11323. selected(wi%,40))
  11324. /      
  11325.  "Expand":
  11326. set_icon(wi%,5,(C$="ON"))
  11327. 3      
  11328.  "ExpHeader":
  11329. set_icon(wi%,37,(C$="ON"))
  11330. 2      
  11331.  "Uppercase":
  11332. set_icon(wi%,6,(C$="ON"))
  11333. 0      
  11334.  "Header":
  11335. set_icon(wi%,28,(C$="ON"))
  11336. .      
  11337.  "Page1":
  11338. set_icon(wi%,4,(C$="ON"))
  11339. 0      
  11340.  "Footer":
  11341. set_icon(wi%,29,(C$="ON"))
  11342. .      
  11343.  "Date":
  11344. set_icon(wi%,11,(C$="ON"))
  11345. 0      
  11346.  "Shrink":
  11347. set_icon(wi%,24,(C$="ON"))
  11348. 4      
  11349.  "PageNumber":
  11350. set_icon(wi%,35,(C$="ON"))
  11351. )      
  11352.  "PageLength":$
  11353. text(wi%,9)=C$
  11354. %      
  11355.  "Title":$
  11356. text(wi%,10)=C$
  11357. )      
  11358.  "TextWidth":$
  11359. text(wi%,18)=C$
  11360. ,      
  11361.  "ColumnSpacer":$
  11362. text(wi%,26)=C$
  11363.       
  11364.  "Orientation":
  11365. /      
  11366. deselect(wi2%,
  11367. selected_esg(wi2%,1))
  11368.       
  11369. '        
  11370.  "upright":
  11371. select(wi2%,3)
  11372. (        
  11373.  "sideways":
  11374. select(wi2%,4)
  11375.         
  11376. select(wi2%,3)
  11377.       
  11378.       
  11379.  "PrintCols":
  11380. /      
  11381. deselect(wi2%,
  11382. selected_esg(wi2%,9))
  11383.       
  11384. "        
  11385.  "1":
  11386. select(wi2%,80)
  11387. "        
  11388.  "2":
  11389. select(wi2%,81)
  11390. "        
  11391.  "3":
  11392. select(wi2%,85)
  11393. "        
  11394.  "4":
  11395. select(wi2%,86)
  11396.         
  11397. select(wi2%,80)
  11398.       
  11399. .      
  11400. shade(wi2%,82,
  11401. selected(wi2%,80))
  11402. '      
  11403.  "Gutter":$
  11404. text(wi2%,82)=C$
  11405. +      
  11406.  "HeaderFont":$
  11407. text(wi2%,57)=C$
  11408. )      
  11409.  "BodyFont":$
  11410. text(wi2%,71)=C$
  11411.       
  11412.  "FontSize":
  11413. /      
  11414. deselect(wi2%,
  11415. selected_esg(wi2%,7))
  11416.       
  11417. shade(wi2%,65,
  11418.       
  11419. "        
  11420.  "8":
  11421. select(wi2%,61)
  11422. #        
  11423.  "10":
  11424. select(wi2%,62)
  11425. #        
  11426.  "12":
  11427. select(wi2%,63)
  11428. #        
  11429.  "14":
  11430. select(wi2%,64)
  11431. 2        
  11432. text(wi2%,65)=C$:
  11433. shade(wi2%,65,
  11434.       
  11435. 2      
  11436.  "Hcolour":
  11437. set_icon_cols(wi%,53,
  11438. (C$))
  11439. 2      
  11440.  "Bcolour":
  11441. set_icon_cols(wi%,54,
  11442. (C$))
  11443. 2      
  11444.  "Rcolour":
  11445. set_icon_cols(wi%,55,
  11446. (C$))
  11447.       
  11448.  "Margins":
  11449.        live%()=14,15,16,18,-1
  11450.       
  11451.  C$="printer" 
  11452. ,        
  11453. select(wi2%,68):
  11454. enable(wi2%,
  11455. 0        
  11456. deselect(wi2%,68):
  11457. enable(wi2%,
  11458.       
  11459.         
  11460. (      
  11461.  "Lmargin":$
  11462. text(wi2%,14)=C$
  11463. (      
  11464.  "Rmargin":$
  11465. text(wi2%,15)=C$
  11466. (      
  11467.  "Tmargin":$
  11468. text(wi2%,16)=C$
  11469. (      
  11470.  "Bmargin":$
  11471. text(wi2%,18)=C$
  11472.       
  11473.  "LineSpace":
  11474. !      
  11475. C$)<>"%" 
  11476.  C$="120%"
  11477.       $
  11478. text(wi2%,56)=C$
  11479. '      
  11480.  "Copies":$
  11481. text(wi2%,45)=C$
  11482.       
  11483.  "TabColumns":
  11484.       P%=
  11485. C$,",")
  11486. #      $
  11487. text(wi2%,23)=
  11488. C$,P%-1)
  11489. #      $
  11490. text(wi2%,24)=
  11491. C$,P%+1)
  11492. <      
  11493.  "ExtraRows":$
  11494. text(wi2%,69)=
  11495. (C$))            
  11496.       
  11497.  "LabelRowOf":
  11498. /      
  11499. deselect(wi2%,
  11500. selected_esg(wi2%,5))
  11501.       
  11502. (C$) 
  11503.          
  11504. select(wi2%,28)
  11505.          
  11506. select(wi2%,29)
  11507.          
  11508. select(wi2%,30)
  11509.          
  11510. select(wi2%,53)
  11511.       
  11512. +      
  11513.  "LabelWidth":$
  11514. text(wi2%,32)=C$
  11515. ,      
  11516.  "LabelHeight":$
  11517. text(wi2%,34)=C$
  11518.       
  11519.  "Substitute":
  11520.       P%=
  11521. C$,"|")
  11522.       
  11523.  P%>0 
  11524.         
  11525. select(wi2%,39)
  11526. %        $
  11527. text(wi2%,78)=
  11528. C$,P%-1)
  11529. %        $
  11530. text(wi2%,40)=
  11531. C$,P%+1)
  11532. F        
  11533. deselect(wi2%,39):$
  11534. text(wi2%,78)="":$
  11535. text(wi2%,40)=""
  11536.       
  11537. 7      
  11538. shade(wi2%,78,(P%>0)):
  11539. shade(wi2%,40,(P%>0))
  11540. *      
  11541.  "FirstLine":$
  11542. text(wi2%,51)=C$
  11543. )      
  11544.  "LastLine":$
  11545. text(wi2%,52)=C$
  11546. 3      
  11547.  "PrintKey":
  11548. set_icon(wi2%,41,(C$="ON"))
  11549.       
  11550.  "Units":
  11551. /      
  11552. deselect(wi2%,
  11553. selected_esg(wi2%,8))
  11554.       
  11555. #        
  11556.  "mm":
  11557. select(wi2%,48)
  11558. #        
  11559.  "in":
  11560. select(wi2%,38)
  11561. #        
  11562.  "pt":
  11563. select(wi2%,77)
  11564.       
  11565.       
  11566. label_units(C$)
  11567.       
  11568.  "SortOn":
  11569. $      
  11570. set_icon(wi%,46,(C$<>""))
  11571.       $
  11572. text(wi%,44)=C$
  11573. !      
  11574. shade(wi%,44,(C$<>""))
  11575. !    0      
  11576.  "SortDir":
  11577. set_icon(wi%,47,(C$="A"))
  11578. 0      
  11579.  "Pause":
  11580. set_icon(wi2%,87,(C$="ON"))
  11581.         
  11582. close_file(F)
  11583. enable_print_setup(wi%,wi2%)
  11584. save_options(wi%,wi2%,f$)
  11585. selected_esg(wi%,4) 
  11586.  23:C$="file"
  11587.  25:C$="printer"
  11588. :C$="window"
  11589. #F,"Destination "+C$
  11590. selected_esg(wi%,1) 
  11591.  2:C$="descriptor"
  11592.  36:C$="none"
  11593. :C$="tag"
  11594. #F,"Headings "+C$
  11595. !"#  
  11596. selected(wi%,16):C$="vert"
  11597. !#$  
  11598. selected(wi2%,7):C$="table"
  11599. !$$  
  11600. selected(wi2%,8):C$="label"
  11601. :C$="horiz"
  11602. #F,"Format "+C$
  11603. selected_esg(wi%,6) 
  11604.  41:C$="Columns"
  11605. :C$="Single row"
  11606. #F,"Scroller "+C$
  11607. #F,"CellSep "+$
  11608. text(wi%,50)
  11609. #F,"RowTerm "+$
  11610. text(wi%,51)
  11611. selected(wi%,43) 
  11612.  C$="ON" 
  11613.  C$="OFF"
  11614. #F,"ShrinkRow "+C$
  11615. selected(wi%,5) 
  11616.  C$="ON" 
  11617.  C$="OFF"
  11618. #F,"Expand "+C$
  11619. selected(wi%,37) 
  11620.  C$="ON" 
  11621.  C$="OFF"
  11622. #F,"ExpHeader "+C$
  11623. selected(wi%,6) 
  11624.  C$="ON" 
  11625.  C$="OFF"
  11626. #F,"Uppercase "+C$
  11627. selected(wi%,28) 
  11628.  C$="ON" 
  11629.  C$="OFF"
  11630. #F,"Header "+C$
  11631. selected(wi%,4) 
  11632.  C$="ON" 
  11633.  C$="OFF"
  11634. #F,"Page1 "+C$
  11635. selected(wi%,29) 
  11636.  C$="ON" 
  11637.  C$="OFF"
  11638. #F,"Footer "+C$
  11639. selected(wi%,11) 
  11640.  C$="ON" 
  11641.  C$="OFF"
  11642. #F,"Date "+C$
  11643. selected(wi%,24) 
  11644.  C$="ON" 
  11645.  C$="OFF"
  11646. #F,"Shrink "+C$
  11647. selected(wi%,35) 
  11648.  C$="ON" 
  11649.  C$="OFF"
  11650. #F,"PageNumber "+C$
  11651. #F,"PageLength "+$
  11652. text(wi%,9)
  11653. #F,"Title "+$
  11654. text(wi%,10)
  11655. #F,"TextWidth "+$
  11656. text(wi%,18)
  11657. #F,"ColumnSpacer "+$
  11658. text(wi%,26)
  11659. selected_esg(wi2%,1) 
  11660.  4:C$="sideways"
  11661. :C$="upright"
  11662. #F,"Orientation "+C$
  11663. selected_esg(wi2%,9) 
  11664.  81:C$="2"
  11665.  85:C$="3"
  11666.  86:C$="4"
  11667. :C$="1"
  11668. #F,"PrintCols "+C$
  11669. #F,"Gutter "+$
  11670. text(wi2%,82)
  11671. #F,"HeaderFont "+$
  11672. text(wi2%,57)
  11673. #F,"BodyFont "+$
  11674. text(wi2%,71)
  11675. selected_esg(wi2%,7) 
  11676.  61:C$="8"
  11677.  62:C$="10"
  11678.  63:C$="12"
  11679.  64:C$="14"
  11680. :C$=$
  11681. text(wi2%,65)
  11682. #F,"FontSize "+C$
  11683. !^ C$=
  11684. get_icon_cols(wi%,53))
  11685. #F,"Hcolour "+C$
  11686. !` C$=
  11687. get_icon_cols(wi%,54))
  11688. #F,"Bcolour "+C$
  11689. !b C$=
  11690. get_icon_cols(wi%,55))
  11691. #F,"Rcolour "+C$
  11692. selected(wi2%,68) 
  11693.  C$="printer" 
  11694.  C$="program"
  11695. #F,"Margins "+C$
  11696. #F,"Lmargin "+$
  11697. text(wi2%,14)
  11698. #F,"Rmargin "+$
  11699. text(wi2%,15)
  11700. #F,"Tmargin "+$
  11701. text(wi2%,16)
  11702. #F,"Bmargin "+$
  11703. text(wi2%,18)
  11704. text(wi2%,56)
  11705. C$)<>"%" 
  11706.  C$+="%"
  11707. #F,"LineSpace "+C$
  11708. #F,"Copies "+$
  11709. text(wi2%,45)
  11710. #F,"TabColumns "+$
  11711. text(wi2%,23)+","+$
  11712. text(wi2%,24)
  11713. #F,"ExtraRows "+$
  11714. text(wi2%,69)
  11715. selected_esg(wi2%,5) 
  11716.  28:C%=1
  11717.  29:C%=2
  11718.  53:C%=4
  11719. :C%=3
  11720. #F,"LabelRowOf "+C$
  11721. #F,"LabelWidth "+$
  11722. text(wi2%,32)
  11723. #F,"LabelHeight "+$
  11724. text(wi2%,34)
  11725. selected(wi2%,39) 
  11726.  C$=$
  11727. text(wi2%,78)+"|"+$
  11728. text(wi2%,40) 
  11729.  C$="OFF"
  11730. #F,"Substitute "+C$
  11731. #F,"FirstLine "+$
  11732. text(wi2%,51)
  11733. #F,"LastLine "+$
  11734. text(wi2%,52)
  11735. selected(wi2%,41) 
  11736.  C$="ON" 
  11737.  C$="OFF"
  11738. #F,"PrintKey "+C$
  11739. selected_esg(wi2%,8) 
  11740.  38:C$="in"
  11741.  77:C$="pt"
  11742. :C$="mm"
  11743. #F,"Units "+C$
  11744. selected(wi%,46) 
  11745.  C$=$
  11746. text(wi%,44) 
  11747.  C$=""
  11748. #F,"SortOn "+C$
  11749. selected(wi%,47) 
  11750.  C$="A" 
  11751.  C$="D"
  11752. #F,"SortDir "+C$
  11753. selected(wi2%,87) 
  11754.  C$="ON" 
  11755.  C$="OFF"
  11756. #F,"Pause "+C$
  11757. close_file(F)
  11758.  "OS_File",18,f$,&7f5
  11759. get_preferences(wi%,f$)
  11760.  F,S$,C$,P%
  11761.   S$=
  11762. S$,1)<>"|" 
  11763. -    P%=
  11764. S$," "):C$=
  11765. S$,P%+1):S$=
  11766. S$,P%-1)
  11767. (      
  11768.  "DateSeparator":$datesep%=C$
  11769. (      
  11770.  "TimeSeparator":$timesep%=C$
  11771.       
  11772.  "WildcardS":$wc%=C$
  11773.       
  11774.  "WildcardM":$ws%=C$
  11775. 5      
  11776.  "Recalculate":
  11777. set_icon(wi%,14,(C$="ON"))
  11778. @      
  11779.  "NewCopy":kill%=(C$<>"ON"):
  11780. set_icon(wi%,12,
  11781.  kill%)
  11782. U      
  11783.  "CaseSpecific":
  11784. set_icon(wi%,30,(C$="ON")):
  11785. set_icon(queryW%,1,(C$="ON"))
  11786. 5      
  11787.  "BlankRecord":
  11788. set_icon(wi%,15,(C$="ON"))
  11789. 8      
  11790.  "MoveDescriptor":
  11791. set_icon(wi%,16,(C$="ON"))
  11792. C      
  11793.  "ImpulseClient":$mergewith%=C$:$ImpulseApp%=$mergewith%
  11794. P      
  11795.  "Validate":
  11796. set_icon(wi%,21,(C$="ON")):
  11797. shade(keypadW%,18,(C$="ON"))
  11798. 4      
  11799.  "ShowLinked":
  11800. set_icon(wi%,19,(C$="ON"))
  11801. 1      
  11802.  "Warning":
  11803. set_icon(wi%,20,(C$="ON"))
  11804.       
  11805.  "Autosave":
  11806. -      
  11807. deselect(wi%,
  11808. selected_esg(wi%,2))
  11809.       
  11810. C$,4) 
  11811. /        
  11812.  "OFF":autosave%=0:$Interval%="10"
  11813. 2        
  11814.  "WARN":autosave%=1:$Interval%=
  11815. C$,5)
  11816. 2        
  11817.  "AUTO":autosave%=2:$Interval%=
  11818. C$,5)
  11819.       
  11820. #      
  11821. select(wi%,29-autosave%)
  11822. '      
  11823. shade(wi%,25,(autosave%<>0))
  11824.       
  11825.  "Autobalance":
  11826.       
  11827. C$,4) 
  11828. /        
  11829.  "OFF":autobalance%=
  11830. :$Every%="25"
  11831. 2        
  11832.  "AUTO":$Every%=
  11833. C$,5):autobalance%=
  11834.       
  11835. I      
  11836. set_icon(wi%,31,autobalance%):
  11837. shade(wi%,32,
  11838. selected(wi%,31))
  11839. ,      
  11840.  "Duplication":dupwarn%=(C$="ON")
  11841. L      
  11842. set_icon(wi%,34,dupwarn%):
  11843. shade(prefsW%,34,
  11844. selected(passW%,15))
  11845. 5      
  11846.  "DefaultAction":
  11847. set_icon(wi%,41,C$="ON")
  11848. 4      
  11849.  "StripLeading":
  11850. set_icon(wi%,47,C$="ON")
  11851. 5      
  11852.  "StripTrailing":
  11853. set_icon(wi%,42,C$="ON")
  11854. 5      
  11855.  "RememberPlace":
  11856. set_icon(wi%,43,C$="ON")
  11857. 2      
  11858.  "SaveMarked":
  11859. set_icon(wi%,48,C$="ON")
  11860. /      
  11861.  "AutoCSV":
  11862. set_icon(wi%,44,C$="ON")
  11863. 0      
  11864.  "AutoOpen":
  11865. set_icon(wi%,49,C$="ON")
  11866. &      
  11867.  "SaveStart":$StartHere%=C$
  11868.         
  11869. close_file(F)
  11870. save_preferences(wi%,f$)
  11871.  F,C$
  11872. #F,"DateSeparator "+$datesep%
  11873. #F,"TimeSeparator "+$timesep%
  11874. #F,"WildcardS "+$wc%
  11875. #F,"WildcardM "+$ws%
  11876. #F,"ImpulseClient "+$mergewith%
  11877. selected(wi%,12) 
  11878.  C$="ON" 
  11879.  C$="OFF"
  11880. #F,"NewCopy "+C$
  11881. selected(wi%,30) 
  11882.  C$="ON" 
  11883.  C$="OFF"
  11884. #F,"CaseSpecific "+C$
  11885. selected(wi%,14) 
  11886.  C$="ON" 
  11887.  C$="OFF"
  11888. #F,"Recalculate "+C$
  11889. selected(wi%,15) 
  11890.  C$="ON" 
  11891.  C$="OFF"
  11892. #F,"BlankRecord "+C$
  11893. selected(wi%,16) 
  11894.  C$="ON" 
  11895.  C$="OFF"
  11896. #F,"MoveDescriptor "+C$
  11897. selected(wi%,21) 
  11898.  C$="ON" 
  11899.  C$="OFF"
  11900. #F,"Validate "+C$
  11901. selected(wi%,19) 
  11902.  C$="ON" 
  11903.  C$="OFF"
  11904. #F,"ShowLinked "+C$
  11905. selected(wi%,20) 
  11906.  C$="ON" 
  11907.  C$="OFF"
  11908. #F,"Warning "+C$
  11909.  autosave% 
  11910.  0:C$="OFF"
  11911.  1:C$="WARN"+$Interval%
  11912.  2:C$="AUTO"+$Interval%
  11913. #F,"Autosave "+C$
  11914.  autobalance% 
  11915. :C$="OFF"
  11916. :C$="AUTO"+$Every%
  11917. #F,"Autobalance "+C$
  11918. selected(prefsW%,34) 
  11919.  C$="ON" 
  11920.  C$="OFF"
  11921. #F,"Duplication "+C$
  11922. selected(prefsW%,41) 
  11923.  C$="ON" 
  11924.  C$="OFF"
  11925. #F,"DefaultAction "+C$
  11926. selected(prefsW%,47) 
  11927.  C$="ON" 
  11928.  C$="OFF"
  11929. #F,"StripLeading "+C$
  11930. selected(prefsW%,42) 
  11931.  C$="ON" 
  11932.  C$="OFF"
  11933. #F,"StripTrailing "+C$
  11934. selected(prefsW%,43) 
  11935.  C$="ON" 
  11936.  C$="OFF"
  11937. #F,"RememberPlace "+C$
  11938. selected(prefsW%,48) 
  11939.  C$="ON" 
  11940.  C$="OFF"
  11941. #F,"SaveMarked "+C$
  11942. selected(prefsW%,44) 
  11943.  C$="ON" 
  11944.  C$="OFF"
  11945. #F,"AutoCSV "+C$
  11946. selected(prefsW%,49) 
  11947.  C$="ON" 
  11948.  C$="OFF"
  11949. #F,"AutoOpen "+C$
  11950. C$=$StartHere%
  11951.  C$<>"" 
  11952. #F,"SaveStart "+C$
  11953. close_file(F)
  11954.  "OS_File",18,f$,&fff
  11955. get_csv_options(f$)
  11956.  F,S$,C$,P%
  11957.   S$=
  11958. S$,1)<>"|" 
  11959. -    P%=
  11960. S$," "):C$=
  11961. S$,P%+1):S$=
  11962. S$,P%-1)
  11963.       
  11964.  "Separator":
  11965.       $Delim%=""
  11966.       
  11967. #        
  11968.  "Comma":sep$=",":P%=0
  11969. "    "        
  11970.  "TAB":sep$=
  11971. (9):P%=1
  11972. "        
  11973.  "CR":sep$=
  11974. (13):P%=2
  11975. "        
  11976.  "LF":sep$=
  11977. (10):P%=3
  11978. %        
  11979.  $Delim%=C$:sep$=C$:P%=4
  11980.       
  11981. '      
  11982. tick_one(delimiterM%,0,3,P%)
  11983. 4      $
  11984. text(csvW%,14)=C$:
  11985. redraw_icon(csvW%,14)
  11986.       
  11987.  "Terminator":
  11988.       $Termin%=""
  11989.       
  11990. #        
  11991.  "CR":term$=
  11992. (13):P%=0
  11993. #        
  11994.  "LF":term$=
  11995. (10):P%=1
  11996. ,        
  11997.  "CR LF":term$=
  11998. (13)+
  11999. (10):P%=2
  12000. ,        
  12001.  "LF CR":term$=
  12002. (10)+
  12003. (13):P%=3
  12004. ,        
  12005.  "CR CR":term$=
  12006. (13)+
  12007. (13):P%=4
  12008. ,        
  12009.  "LF LF":term$=
  12010. (10)+
  12011. (10):P%=5
  12012. (        
  12013. : $Termin%=C$:term$=C$:P%=6
  12014.       
  12015. (      
  12016. tick_one(terminatorM%,0,5,P%)
  12017. 4      $
  12018. text(csvW%,15)=C$:
  12019. redraw_icon(csvW%,15)
  12020.       
  12021.  "ScrollTerm":
  12022.       $Scrterm%=""
  12023.       
  12024. " .        
  12025.  "Semicolon":scrollterm$=";":P%=0
  12026. "!*        
  12027.  "Comma":scrollterm$=",":P%=1
  12028. "")        
  12029.  "TAB":scrollterm$=
  12030. (9):P%=2
  12031. "#*        
  12032.  "Space":scrollterm$=" ":P%=3
  12033. "$.        
  12034.  $Scrterm%=C$:scrollterm$=C$:P%=4
  12035.       
  12036. "&(      
  12037. tick_one(scrolltermM%,0,3,P%)
  12038. "'4      $
  12039. text(csvW%,27)=C$:
  12040. redraw_icon(csvW%,27)
  12041. "(/      
  12042.  "Quotes":
  12043. set_icon(csvW%,0,C$="ON")
  12044. ")/      
  12045.  "Header":
  12046. set_icon(csvW%,1,C$="ON")
  12047. "*/      
  12048.  "Blanks":
  12049. set_icon(csvW%,2,C$="ON")
  12050. "+,      
  12051.  "Key":
  12052. set_icon(csvW%,3,C$="ON")
  12053. ",/      
  12054.  "RecNo":
  12055. set_icon(csvW%,22,C$="ON")
  12056. "-D      
  12057.  "Data":
  12058. set_icon(csvW%,4,(C$="ON" 
  12059. selected(csvW%,1)))
  12060. ".1      
  12061.  "Display":
  12062. set_icon(csvW%,11,C$="ON")
  12063. "//      
  12064.  "Strip":
  12065. set_icon(csvW%,16,C$="ON")
  12066. "00      
  12067.  "NewSeq":
  12068. set_icon(csvW%,23,C$="ON")
  12069. "1        
  12070. shade(csvW%,4,(
  12071. selected(csvW%,1)))
  12072. close_file(F)
  12073. save_csv_options(f$)
  12074.  F,C$
  12075. selected(csvW%,0) 
  12076.  C$="ON" 
  12077.  C$="OFF"
  12078. #F,"Quotes "+C$
  12079. selected(csvW%,1) 
  12080.  C$="ON" 
  12081.  C$="OFF"
  12082. #F,"Header "+C$
  12083. selected(csvW%,2) 
  12084.  C$="ON" 
  12085.  C$="OFF"
  12086. #F,"Blanks "+C$
  12087. selected(csvW%,3) 
  12088.  C$="ON" 
  12089.  C$="OFF"
  12090. #F,"Key "+C$
  12091. selected(csvW%,22) 
  12092.  C$="ON" 
  12093.  C$="OFF"
  12094. #F,"RecNo "+C$
  12095. selected(csvW%,4) 
  12096.  C$="ON" 
  12097.  C$="OFF"
  12098. #F,"Data "+C$
  12099.  sep$ 
  12100.  ",":C$="Comma"
  12101. (9):C$="TAB"
  12102. (10):C$="LF"
  12103. (13):C$="CR"
  12104. :C$=sep$
  12105. #F,"Separator "+C$
  12106.  term$ 
  12107. (13):C$="CR"
  12108. (10):C$="LF"
  12109. (13)+
  12110. (10):C$="CR LF"
  12111. (10)+
  12112. (13):C$="LF CR"
  12113. (13)+
  12114. (13):C$="CR CR"
  12115. (10)+
  12116. (10):C$="LF LF"
  12117. :C$=term$
  12118. #F,"Terminator "+C$
  12119.  scrollterm$ 
  12120.  ";":C$="Semicolon"
  12121.  ",":C$="Space"
  12122. (9):C$="TAB"
  12123. :C$=scrollterm$
  12124. #F,"ScrollTerm "+C$
  12125. selected(csvW%,11) 
  12126.  C$="ON" 
  12127.  C$="OFF"
  12128. #F,"Display "+C$
  12129. selected(csvW%,16) 
  12130.  C$="ON" 
  12131.  C$="OFF"
  12132. #F,"Strip "+C$
  12133. selected(csvW%,23) 
  12134.  C$="ON" 
  12135.  C$="OFF"
  12136. #F,"NewSeq "+C$
  12137. close_file(F)
  12138.  "OS_File",18,f$,&fff
  12139. load_indexes
  12140.  f$,menu$,R4%,ptr%
  12141. "l*f$=$database%+".Indexes":R4%=0:Keys%=0
  12142. menu$="indexes,"
  12143.  R4%<>-1
  12144.   Keys%+=1
  12145. "p4  
  12146.  "OS_GBPB",9,f$,block%,1,R4%,255 
  12147.  ,,K$,,R4%
  12148.  R4%<>-1 
  12149.     hidden%=
  12150. "s&    
  12151. load_index(f$+"."+K$,Keys%,
  12152. "t2    
  12153.  hide%?KF%(Keys%,0)<>1 
  12154. colour(Keys%,2)
  12155. "w Keys%-=1:
  12156. colour(0,1):key%=0
  12157.  extrakeys$<>"" 
  12158. softerror(
  12159. (MaxKeys%)+",subsidiary indexes,"+
  12160. extrakeys$)+",Keys",96)
  12161. make_index_menu
  12162. load_index(f$,key%,merge%)
  12163.  keybase%,I%,name$
  12164. leaf(f$),3)="Del" 
  12165.  Keys%-=1:
  12166.  key%>MaxKeys% 
  12167.  merge% 
  12168.  extrakeys$+=
  12169. leaf(f$)+",":Keys%-=1:
  12170.  "OS_File",5,f$ 
  12171.  ,,,,len%
  12172. name$=
  12173. leaf(f$)
  12174. FSHkeyptr%(key%)=
  12175. extend_named_sliding_block(keyanchor%(key%),len%)
  12176. keybase%=SHkeyptr%(key%)
  12177.  "OS_File",255,f$,keybase%
  12178. Index$(key%)=name$
  12179.  key%=0 
  12180.  I%=0 
  12181. %    $Date%(I%)=$(keybase%+8+9*I%)
  12182. KL%(key%)=keybase%?70
  12183.  I%=0 
  12184. &  KW%(key%,I%)=!(keybase%+74+I%*4)
  12185. +  KF%(key%,I%)=(KW%(key%,I%)>>24) 
  12186. !case%(key%)=(keybase%?71=255)
  12187. %incspace%(key%)=(keybase%?72=255)
  12188. !null%(key%)=(keybase%?73=255)
  12189.  keybase%!62>0 
  12190.  ### Old key structure applies ###
  12191.   words%=
  12192.  I%=0 
  12193.  KW%(key%,I%)>0 
  12194. "      KF%(key%,I%)=keybase%!62
  12195. K      KW%(key%,I%)=!(keybase%+74+I%*4)+((I%+1)<<16)+((keybase%!62)<<24)
  12196.       words%=
  12197.         
  12198.  words% 
  12199.  KF%(key%,0)=keybase%!62:KW%(key%,0)=KL%(key%)+((keybase%!62)<<24)
  12200.  keybase%!66>0 
  12201.  I%=1 
  12202.       
  12203.  KW%(key%,I%)>0 
  12204. $        KF%(key%,I%)=keybase%!66
  12205. I        KW%(key%,I%)=!(keybase%+74+I%*4)+(I%<<16)+((keybase%!66)<<24)
  12206.       
  12207. load_user_functions(f$)
  12208.  func$,d%,R4%
  12209.  "OS_File",5,f$+".UserFuncs" 
  12210.  f$+".UserFuncs"
  12211.  "OS_File",8,f$+".xyzzy"
  12212.  "OS_CLI","Rename "+f$+".UserFuncs "+f$+".xyzzy.UserFuncs"
  12213.  "OS_CLI","Rename "+f$+".xyzzy "+f$+".UserFuncs"
  12214.   f$+=".UserFuncs"
  12215. 9    
  12216.  "OS_GBPB",9,f$,block%,1,R4%,255 
  12217.  ,,func$,,R4%
  12218. #    
  12219.  R4%<>-1 
  12220.  f$+"."+func$
  12221.  R4%=-1  
  12222. get_tables
  12223.  F,F%,d%,R4%,f$,file$,name$,subst%,field%,exact%,scrcol%,type%,err%
  12224. %f$=$database%+".ValTables.":R4%=0
  12225. lit(validateM%,0,
  12226. ($database%+".Link")
  12227.  F>0 
  12228.   !block%=mainW%
  12229.     F%+=1
  12230. #F,link$(F%)
  12231.     name$=link$(F%)
  12232. name$,1)="@" 
  12233.       
  12234.  chartype%(F%) 
  12235. 9        
  12236.  35:$
  12237. val(mainW%,field%(F%))="R5;Sdirectory"
  12238.         
  12239.         file$=
  12240. name$,2)
  12241. 0        file$=
  12242. filename(file$,"PrintRes",-1)
  12243. 2        
  12244.  "XOS_File",5,file$ 
  12245.  d%,,type%;err%
  12246.         
  12247.  (err% 
  12248.  1)=1 
  12249.           link$(F%)=""
  12250. A          
  12251. softerror(file$+","+
  12252. leaf(file$)+","+Tag$(F%),121)
  12253.           
  12254.           
  12255.  d%=1 
  12256. '            type%=(type%>>8) 
  12257.  &fff
  12258. >            $
  12259. val(mainW%,field%(F%))="R5;Sfile_"+
  12260. ~(type%)
  12261.           
  12262.         
  12263.       
  12264.       
  12265. /      field%=
  12266. trailing_number(name$,exact%)
  12267.       
  12268.  name$<>"" 
  12269. 1        subst%=
  12270. leading_number(scrcol%,name$)
  12271. (        
  12272.  "OS_File",5,f$+name$ 
  12273.         
  12274.  d%=1 
  12275. %          
  12276. load_table(f$+name$,
  12277.           
  12278.  scrcol%>0 
  12279. 5            
  12280. colour_scroller(F%,scrcol%,fcol%(8))
  12281. <            
  12282. set_icon_cols(mainW%,field%(F%),fcol%(8))
  12283.           
  12284. $          
  12285. softerror(name$,31)
  12286.         
  12287.       
  12288.         
  12289.   link$(0)="LOADED"
  12290. close_file(F)
  12291.  ### Force loading of unlinked but flagged tables ###
  12292.  ### The use of "!" to flag tables sometimes gives an error. Use "+" ###
  12293.  R4%<>-1
  12294.  "OS_GBPB",9,
  12295. f$),block%,1,R4%,255 
  12296.  ,,name$,,R4%
  12297.  R4%<>-1 
  12298. name$) 
  12299. +      
  12300.  "+","!":
  12301. load_table(f$+name$,
  12302.         
  12303.  T%=LastTable%+1 
  12304.  MaxTabs%
  12305. A  SHtabptr%(T%)=
  12306. extend_named_sliding_block(tabanchor%(T%),4)
  12307.  extratabs$<>"" 
  12308. softerror(
  12309. (MaxTabs%)+",tables,"+
  12310. extratabs$)+",Tabs",96)
  12311. make_table_menu(TabsLoaded$)
  12312. load_calcs
  12313.  F,I%,F%,F1%,P%,calc$,file%,top
  12314. update$()=""
  12315. ($database%+".Calc")
  12316.  F>0 
  12317. +    F%+=1:F$=
  12318. ~(F%):
  12319.  F%<16 
  12320.  F$="0"+F$
  12321. !    
  12322. #F,calc$:calc$(F%)=calc$
  12323.  chartype%(F%) 
  12324.       
  12325.  6,7:
  12326.       
  12327. !        P%=
  12328. calc$,"$Rf%(",P%)
  12329. ?        
  12330.  P%>0 
  12331.  F1%=
  12332. calc$,P%+5)):update$(F1%)+=F$:P%+=5
  12333.       
  12334.  P%=0
  12335.       
  12336.          P%=
  12337. calc$,"FNn(",P%)
  12338. ?        
  12339.  P%>0 
  12340.  F1%=
  12341. calc$,P%+4)):update$(F1%)+=F$:P%+=4
  12342.       
  12343.  P%=0
  12344. .      
  12345. calc$,"TIME$")>0 
  12346.  update$(0)+=F$
  12347.         
  12348.   calc$(0)="LOADED"
  12349. close_file(F)
  12350. selected(prefsW%,14) 
  12351. ,  dbasehandle%=
  12352. ($database%+".Database")
  12353.  "Hourglass_On"
  12354.  file%=0 
  12355.     top=8*file%+LH%
  12356. !    P%=
  12357. neighbour(key%,top,1)
  12358. P    
  12359.  update$(0)<>"" 
  12360.  updatethese%=
  12361. scan_file("P%<>top",key%,file%,6,1)
  12362.  file%
  12363.  "Hourglass_Off"
  12364. close_file(dbasehandle%)
  12365.  I%=1 
  12366.  fields%
  12367.  chartype%(I%) 
  12368. $      
  12369.  21,27,28,32,34,40,45,59:
  12370. # O      
  12371.  $Rf%(I%) holds key legend or other important data. Don't overwrite!
  12372.       
  12373. :$Rf%(I%)=field$(I%)
  12374. redraw(mainW%)
  12375. field_data
  12376. print_init("W")
  12377.  I%,V%,tab%,S$,M$,M%,P%
  12378. #+DTextName$=$database%+".PrintJobs.FieldData":$SaveName%=TextName$
  12379. #,7format$="fields":LenLine%=Lmargin%+93:tab%=Lmargin%
  12380. spacer$,"|")>0 
  12381.  spacer$="|"
  12382. Tab%()=0,1,7,23,43,47,52,57
  12383. #/8maxhead%=0:fspace%=18:hspace%=3*36-18:PrintFields%=6
  12384. end_line
  12385. send_title("Description of fields")
  12386. send_title("Field Class           Type                Len Tag  Descriptor")
  12387. M$="ECTXKOSL"
  12388.  "Hourglass_On"
  12389.  I%=1 
  12390.  fields%
  12391. #89  S$=
  12392. "   "+
  12393. (I%),4):
  12394. store_string(S$,tab%,
  12395. ):tab%+=6
  12396. #9?  V%=chartype%(I%):M%=
  12397. M$,vtype$(V%))-1:P%=
  12398. fmenu$(M%),",")
  12399. #:6  
  12400. store_string(
  12401. fmenu$(M%),P%-1),tab%,
  12402. ):tab%+=16
  12403. #;%  S$=
  12404. (V%),2)+" "+vname$(V%)
  12405. #<'  
  12406. store_string(S$,tab%,
  12407. ):tab%+=20
  12408. #=>  S$=
  12409. "  "+
  12410. (len%(I%)),3):
  12411. store_string(S$,tab%,
  12412. ):tab%+=4
  12413. #>,  
  12414. store_string(Tag$(I%),tab%,
  12415. ):tab%+=5
  12416. #?4  
  12417. store_string($
  12418. text(mainW%,desc%(I%)),tab%,
  12419.   tab%=Lmargin%
  12420.  "Hourglass_Off"
  12421. nosort%=
  12422. screen_list
  12423. write_log(-1,"Field data printed","")
  12424. get_form(
  12425.  Fptr%)
  12426.  F,L%,N%,I%,V%,x%,y%,xlim%,ylim%,text%,width%,nwidth%,resave%,num%,Ex%
  12427.  design% 
  12428.  dval%=hand% 
  12429.  dval%=-1
  12430. ($database%+".Form")
  12431.  F>0 
  12432. #NB  SHformptr%=
  12433. extend_named_sliding_block(formanchor%,SHclaim%)
  12434. #F,N%
  12435. #PB  
  12436.  N%>127 
  12437. close_file(F):
  12438.  fatal_err%,
  12439. msg("Err207,"+
  12440. (N%))
  12441. #Qd  
  12442.  N%>MaxFields% 
  12443. close_file(F):
  12444.  fatal_err%,
  12445. msg("Err98,"+
  12446. (N%)+","+
  12447. (MaxFields%)+",Fields")
  12448. #R7  Fptr%=SHformptr%:Rf%(0)=Fptr%:$Rf%(0)="":Fptr%+=1
  12449.   Length%=0
  12450.  I%=1 
  12451. #U@    
  12452. #F,Desc$,Tag$(I%),xd%,yd%,xf%,yf%,len%,char%,fix%,bbox%
  12453. #V3    
  12454.  (char% 
  12455.  128)>0 
  12456.  hide%?I%=1 
  12457.  hide%?I%=0
  12458. #W=    
  12459.  (char% 
  12460.  256)>0 
  12461.  mandatory%?I%=1 
  12462.  mandatory%?I%=0
  12463. #XA    
  12464.  (char% 
  12465.  512)>0 
  12466.  displayit%?I%=1 
  12467.  displayit%?I%=0    
  12468. #Y.    
  12469.  char%>67 
  12470.  char%<79 
  12471.  updatethese%=
  12472.     char%=char% 
  12473. #[0    
  12474.  len%=0 
  12475.  dbtype$="new" 
  12476.  zerolen%?I%=1
  12477. #]B      
  12478.  hide%?I%=1:dflg%=(winback%<<28)+(winback%<<24)+&01A711
  12479. #^2      
  12480.  Desc$="":dflg%=(winback%<<28)+&701A711
  12481. #_)      
  12482. :dflg%=(winback%<<28)+&701A731
  12483. #`        
  12484. #a.    width%=bbox% 
  12485.  &FFFF:height%=bbox%>>16
  12486.  len%>0 
  12487. #c,      
  12488.  height%=0 
  12489.  height%=48:resave%=
  12490. #d2      
  12491.  width%=0 
  12492.  width%=len%*16+16:resave%=
  12493.     $boxW%=
  12494. (width%)
  12495. #gG    
  12496.  ### Following IF...THEN corrects for desktop font changes ###
  12497. #h,    
  12498.  FontAdjust% 
  12499.  vtype$(char%)<>"L" 
  12500. #i1      nwidth%=
  12501. guess_width(len%,char%,width%)
  12502. #j:      
  12503.  len%>0 
  12504. (nwidth%-width%)<80 
  12505.  width%=nwidth%
  12506. #k        
  12507. #l>    
  12508.  design% 
  12509.  fval%=hvalid%(char%) 
  12510.  fval%=valid%(char%)
  12511. #m"    x%=xf%+width%+32:y%=yf%-16
  12512.  x%>xlim% 
  12513.  xlim%=x%
  12514.  y%<ylim% 
  12515.  ylim%=y%
  12516. #p'    y%=yd%-16:
  12517.  y%<ylim% 
  12518.  ylim%=y%
  12519. #q)    
  12520.  zerolen%?I%=0 
  12521.  Length%+=len%+1
  12522. #rF    
  12523.  design%=
  12524.  char%=39 
  12525.  len%=(height% 
  12526.  40)*((width% 
  12527.  16)-4)
  12528. #s7    len%(I%)=len%:chartype%(I%)=char%:fix%(I%)=fix%
  12529.     L%=
  12530. (Desc$)
  12531. #uF    SHformptr%=
  12532. claim_page(formanchor%,Fptr%-SHformptr%+L%+len%+2)
  12533.     $Fptr%=Desc$
  12534. #w$    dwidth%=
  12535. string_width(Desc$)
  12536. #xK    
  12537.  yd%>=yf% 
  12538.  yd%+44<=yf%+height% 
  12539.  xd%<xf% 
  12540.  xd%=xf%-dwidth%       
  12541. #yU    desc%(I%)=
  12542. create_icon(0,mainW%,xd%,yd%,dwidth%,44,dflg%,"",Fptr%,dval%,L%+1)
  12543. #z-    Fptr%+=L%+1:Rf%(I%)=Fptr%:$Rf%(I%)=""
  12544. #{0    
  12545.  char%=35 
  12546.  char%=44 
  12547.  len%=NameLength%
  12548.  char% 
  12549. #}@      
  12550.  59:fval%=SHlogoptr%:$Fptr%=Tag$(I%):len%=
  12551. (Tag$(I%))
  12552. #~j      
  12553.  9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31:buttonfield%(0,char%-9)=I%
  12554. !      
  12555. check_menu_button
  12556.       
  12557.  35,44,60,61,62:
  12558.        V%=valid%(char%):L%=30
  12559. C      SHformptr%=
  12560. claim_page(formanchor%,Fptr%-SHformptr%+L%+2)
  12561. F      fval%=Fptr%:$fval%=$V%:Fptr%+=L%+1:Rf%(I%)=Fptr%:$Rf%(I%)=""
  12562. 5      
  12563.  char%=60 
  12564.  Fptr%+=len%+1:$Fptr%="":len%=0
  12565.         
  12566. M    field%(I%)=
  12567. icon_design(I%,char%,xf%,yf%,width%,height%,fval%,len%,
  12568.  char% 
  12569. .      
  12570.  3,6,46,47,54,56,57,74,75,77,78,79:
  12571. 1      
  12572. icon_bit(9,mainW%,field%(I%),
  12573. ):num%=
  12574. (      
  12575.  Right-justify numeric fields
  12576. 3      
  12577.  64,65,66,67:
  12578. rename_directory(I%,char%)
  12579. L      
  12580. make_scroller(Scrollnum%,I%,xf%,yf%,width%,height%,len%,char%-63)
  12581. 6      
  12582.  36,37,38,39,40:
  12583. rename_directory(I%,char%)
  12584.         
  12585. close_file(F)
  12586.   numericfields%=0
  12587. set_up_select(N%,numericfields%)
  12588.  N%=0
  12589. 7!block%=0:block%!4=ylim%:block%!8=xlim%:block%!12=0
  12590.  "Wimp_SetExtent",mainW%,block%
  12591. JTag$(0)="RECORD":Tag$(MaxFields%+1)="KEY":Tag$(MaxFields%+2)="SUBFILE"
  12592.  resave% 
  12593.  fields%=N%:
  12594. save_form($database%+".Form")
  12595.  Scrollnum%>MaxLists% 
  12596.  Scrollnum%=MaxLists%:
  12597.  fatal_err%,
  12598. msg("Err32,"+
  12599. (Scrollnum%)+",scrollable lists,"+
  12600. (MaxLists%)+",Scrolls")
  12601.  Ex%>0 
  12602. save_renamed(Ex%)
  12603. check_menu_button
  12604. (Tag$(I%))
  12605.  Tag$(I%)="":Tag$(I%)=Tag$(I%-1):resave%=
  12606.  F%>0:Tag$(I%)=Tag$(F%):resave%=
  12607.  Assume button already has same tag as menufield
  12608. save_renamed(N%)
  12609.  "OS_CLI","Copy <Pbase$Dir>.Resources.RevertInfo "+$database%+".!Help ~C~V"
  12610. "rename%=
  12611. ($database%+".!Help")
  12612. #rename%=
  12613. #rename%
  12614. #revert%=
  12615. ($database%+".Revert")
  12616. #revert%,"Set Dbase$Dir <Obey$Dir>"
  12617.  I%=0 
  12618.  N%-1
  12619. #rename%,Label$(I%,0)
  12620. #revert%,Label$(I%,1)
  12621. #revert%,"Remove <Dbase$Dir>.!Help"
  12622. #revert%,"Remove <Dbase$Dir>.Revert"
  12623. close_file(rename%)
  12624. close_file(revert%)
  12625.  "OS_File",18,$database%+".Revert",&feb
  12626. Label$()=""
  12627. softerror(
  12628. leaf($database%)+".!Help",215)
  12629. rename_directory(F%,type%)
  12630.  type% 
  12631.  36,39:old$="Memo"+
  12632. (F%):new$=Tag$(F%)+"text"
  12633.  37,40:old$="Sprite"+
  12634. (F%):new$=Tag$(F%)+"sprite"
  12635.  38:old$="Draw"+
  12636. (F%):new$=Tag$(F%)+"draw"
  12637.  64,65,66,67:old$="Scroll"+
  12638. (F%):new$=Tag$(F%)+"scroll"
  12639.  "OS_File",5,$database%+"."+new$ 
  12640.  d%=2 
  12641.  "OS_File",5,$database%+"."+old$ 
  12642.  d%=2 
  12643.  "OS_CLI","Rename "+$database%+"."+old$+" "+$database%+"."+new$
  12644. -  Label$(Ex%,0)=old$+" renamed as: "+new$
  12645. C  Label$(Ex%,1)="Rename <Dbase$Dir>."+new$+" <Dbase$Dir>."+old$
  12646.   Ex%+=1
  12647.  ### Routines to handle scrollable-list fields (types 64,65,66,67) ###
  12648.  ### Databases using such fields are incompatible with earlier versions ###
  12649. make_scroller(
  12650.  N%,F%,x%,y%,w%,h%,L%,cols%)
  12651.  N%>=MaxLists% 
  12652.  N%+=1:
  12653.  handle%,rows%,I%,J%,R%,colwidth%,F,max%,pos%
  12654.  "Wimp_OpenTemplate",,"<Pbase$Dir>.Resources.Templates"
  12655. #handle%=
  12656. new_window("scroll",0)
  12657.  "Wimp_CloseTemplate"
  12658. LSHscrollptr%(N%)=
  12659. extend_named_sliding_block(scrollanchor%(N%),SHclaim%)
  12660. 'f$=$database%+"."+Tag$(F%)+"scroll"
  12661.  "OS_File",8,f$
  12662. scrollerW%(N%)=handle%
  12663. scrolldata%(N%,0)=F%
  12664. scrolldata%(N%,1)=x%
  12665. scrolldata%(N%,2)=y%
  12666. scrolldata%(N%,3)=w%
  12667. scrolldata%(N%,4)=h%
  12668. rows%=(h% 
  12669. Cscrolldata%(N%,5)=rows%*cols%:
  12670.  No.of icons in window initially
  12671. Hscrolldata%(N%,6)=scrolldata%(N%,5):
  12672.  No.of icons for current record
  12673. (f$+".Max")
  12674.  F>0 
  12675.  scrolldata%(N%,7)=
  12676.  scrolldata%(N%,7)=scrolldata%(N%,5):
  12677.  Max.No.of icons for database
  12678. close_file(F)
  12679. scrolldata%(N%,8)=cols%
  12680.  scrolldata%(N%,9) holds Tab number for printing
  12681. ptr%=SHscrollptr%(N%)
  12682. (f$+".Format")
  12683.  I%=0 
  12684.  cols%-1
  12685.  F>0 
  12686.  sclen%(N%,I%)=
  12687.  sclen%(N%,I%)=10
  12688.   max%+=sclen%(N%,I%)+1
  12689. close_file(F)
  12690.  I%=1 
  12691.  rows%
  12692.   pos%=0
  12693.  J%=0 
  12694.  cols%-1
  12695.     L%=sclen%(N%,J%)
  12696. )    colwidth%=((w%-44)*(L%+1)) 
  12697.  max%
  12698. (    flags%=&0000A535+(fcol%(10)<<24)
  12699. g    R%=
  12700. create_icon(0,handle%,pos%,-I%*44-2,colwidth%,46,flags%,"",ptr%,valid%(chartype%(F%)),L%+1)
  12701.     pos%+=colwidth%
  12702.     $
  12703. text(handle%,R%)=""
  12704.     ptr%+=L%+1
  12705. (f$+".Blank")
  12706.  I%=0 
  12707.  scrolldata%(N%,5)-1
  12708. #F,""
  12709. close_file(F)
  12710.  $Reformatted%<>"" 
  12711.  "OS_CLI","Copy "+$Original%+"."+Tag$(F%)+"scroll.Format "+f$+".Format ~V~CF"
  12712. 7!block%=0:block%!4=-h%+2:block%!8=w%-44:block%!12=0
  12713.  "Wimp_SetExtent",handle%,block%
  12714.     N%+=1
  12715. colour_scroller(field%,column%,colour%)
  12716.  S%,ic%,wi%,icons%,cols%
  12717.  column%=0 
  12718. 7colour%=(colour% 
  12719.  %1111) 
  12720.  (fcol%(10) 
  12721.  %11110000)
  12722. scroller_number(field%):wi%=scrollerW%(S%)
  12723. icons%=scrolldata%(S%,6)
  12724. cols%=scrolldata%(S%,8)
  12725.  ic%=0 
  12726.  icons%-1
  12727.  ic% 
  12728.  cols%=column%-1 
  12729. '    
  12730. set_icon_cols(wi%,ic%,colour%)
  12731. +    
  12732. set_icon_cols(wi%,ic%,fcol%(10))
  12733. add_row(S%,wi%,from%,cols%)
  12734.  F%,I%,L%,N%,R%,colwidth%,pos%,w%,max%,valcol%,ptr%,flags%,table$
  12735. $flags%=&0000A535+(fcol%(10)<<24)
  12736. F%=scrolldata%(S%,0)
  12737. table$=link$(F%)
  12738. leading_number(valcol%,table$)
  12739. &!block%=mainW%:block%!4=field%(F%)
  12740.  "Wimp_GetIconState",,block%
  12741. w%=block%!16-block%!8
  12742.  I%=0 
  12743.  cols%-1
  12744.   max%+=sclen%(S%,I%)+1
  12745. ptr%=(from%-1)*max%
  12746. =SHscrollptr%(S%)=
  12747. claim_page(scrollanchor%(S%),ptr%+max%)
  12748.  I%=0 
  12749.  cols%-1
  12750.   L%=sclen%(S%,I%)+1
  12751. $"#  colwidth%=((w%-44)*L%) 
  12752.  max%
  12753. $#s  R%=
  12754. create_icon(0,wi%,pos%,-from%*44-2,colwidth%,46,flags%,"",SHscrollptr%(S%)+ptr%,valid%(chartype%(F%)),L%)
  12755.   pos%+=colwidth%
  12756. $%6  
  12757.  I%=valcol%-1 
  12758. set_icon_cols(wi%,R%,fcol%(8))
  12759. text(wi%,R%)=""
  12760.   ptr%+=L%
  12761. $(1  
  12762. selected(wi%,R%-cols%) 
  12763. select(wi%,R%)
  12764. scrolldata%(S%,6)+=cols%
  12765.  scrolldata%(S%,6)>scrolldata%(S%,7) 
  12766.  scrolldata%(S%,7)=scrolldata%(S%,6)
  12767. $,=!block%=0:block%!4=-from%*44-2:block%!8=w%-44:block%!12=0
  12768.  "Wimp_SetExtent",wi%,block%
  12769. =scrolldata%(S%,6)
  12770. delete_row(S%,wi%,cols%,F%)
  12771.  ic%,icons%,flag%,w%,rows%
  12772. icons%=scrolldata%(S%,6)
  12773.  icons%=scrolldata%(S%,5) 
  12774. =icons%
  12775.  ic%=icons%-cols% 
  12776.  icons%-1
  12777. $5%  
  12778. text(wi%,ic%)<>"" 
  12779.  flag%=
  12780.  flag% 
  12781.   icons%-=cols%
  12782. delete_icons(wi%,icons%)
  12783.   scrolldata%(S%,6)=icons%
  12784.   rows%=icons% 
  12785.  cols%
  12786. $<(  !block%=mainW%:block%!4=field%(F%)
  12787. $=$  
  12788.  "Wimp_GetIconState",,block%
  12789.   w%=block%!16-block%!8
  12790. $??  !block%=0:block%!4=-rows%*44-2:block%!8=w%-44:block%!12=0
  12791. $@$  
  12792.  "Wimp_SetExtent",wi%,block%
  12793. $A   
  12794. set_caret(0,wi%,icons%-1)
  12795. scroll_it(wi%,rows%-1,
  12796. redraw(wi%)
  12797. =icons%
  12798. scroller_click(swi%,sic%,b%,S%)
  12799. validate(Fieldnumber%,T%,N$)=
  12800. b%=(b% 
  12801.  2047)
  12802. $K,wi%=mainW%:ic%=field%(scrolldata%(S%,0))
  12803. identify_field(ic%)
  12804. $M(Scrcol%=(sic% 
  12805.  scrolldata%(S%,8))+1
  12806.   first%=
  12807. find_caret
  12808. $Q*  
  12809. select_range(first%,Fieldnumber%,
  12810. $S(  
  12811. selected(passW%,11) 
  12812.  Modify% 
  12813. set_up_field_menu
  12814. $U#    
  12815. show_menu(mainM%,x%-64,y%)
  12816. relations
  12817. $X:  
  12818.  64:dragfield%=Fieldnumber%:
  12819. init_drag(swi%,sic%,5)
  12820. $YE  
  12821.  256:
  12822. invert(wi%,ic%):
  12823. update_selection(
  12824. selected(wi%,ic%),"")
  12825. $Z"  
  12826.  I%=0 
  12827.  scrolldata%(S%,6)-1
  12828. $[-    
  12829. set_icon(swi%,I%,
  12830. selected(wi%,ic%))
  12831.  1024:
  12832. (-2) 
  12833. $_5    
  12834. enter_tag(Tag$(Fieldnumber%)+"#"+
  12835. (Scrcol%))
  12836. $`        
  12837. $a5    !block%=swi%:
  12838.  "Wimp_GetWindowState",,block%
  12839. $bW    
  12840.  Access% 
  12841.  "Wimp_SetCaretPosition",swi%,sic%,x%-block%!4+block%!20,y%,-1,-1
  12842. $c,    
  12843. selected(prefsW%,19) 
  12844. relations
  12845. scroller_press(wi%,
  12846.  ic%,S%,pressed%)
  12847.  L%,cols%,P%,icons%,row%,col%,ok%
  12848. abort_scroller:
  12849. ok%=-1
  12850. $m"Fieldnumber%=scrolldata%(S%,0)
  12851. icons%=scrolldata%(S%,6)
  12852. cols%=scrolldata%(S%,8)
  12853. row%=(icons% 
  12854.  cols%)+1
  12855. col%=ic% 
  12856.  cols%
  12857. L%=len%(Fieldnumber%)
  12858. cfield$(Fieldnumber%)="#"
  12859.  pressed% 
  12860. $u<  
  12861.  13,398,399,414,415:ok%=
  12862. validate(Fieldnumber%,T%,N$)
  12863.  ok%=0 
  12864.  pressed% 
  12865. $y$  
  12866. select_range(1,fields%,
  12867.  sclen%(S%,col%)>=10 
  12868. $|(    $
  12869. text(wi%,ic%)=
  12870. convert_date(4)
  12871. $}A    
  12872.  sclen%(S%,col%)>=8 
  12873. text(wi%,ic%)=
  12874. convert_date(2)
  12875. redraw_icon(wi%,ic%) 
  12876.  sclen%(S%,col%)>=8 
  12877.     T$=
  12878. -    
  12879. T$,3,1)=$timesep%:
  12880. T$,6,1)=$timesep%
  12881.     $
  12882. text(wi%,ic%)=T$
  12883. redraw_icon(wi%,ic%)
  12884.  21:ScrollChanged%=
  12885. clear_selection:
  12886. restore_caret(starthere%)
  12887. *  changed%=
  12888. update_calcs(Fieldnumber%)
  12889.  ic% 
  12890.  icons%-1:
  12891. (-1) 
  12892. 3      icons%=
  12893. add_row(S%,wi%,row%,cols%):ic%+=1
  12894. 0      
  12895. set_caret(0,wi%,ic%):row%=ic% 
  12896.  cols%
  12897.        
  12898. scroll_it(wi%,row%,
  12899.       
  12900. (      
  12901.  Fieldnumber%=Lastwritable% 
  12902. #        
  12903. close_window(relateW%)
  12904.         ScrollChanged%=
  12905. /        
  12906. check_record 
  12907. display(key%,-1)
  12908. 9        
  12909.  Fieldnumber%=
  12910. next_editable(Fieldnumber%,1)
  12911.       
  12912.         
  12913.     ic%+=1
  12914. .    
  12915. set_caret(0,wi%,ic%):row%=ic% 
  12916.  cols%
  12917. scroll_it(wi%,row%,
  12918. selected(prefsW%,19) 
  12919. relations
  12920.  398,414:
  12921. *  changed%=
  12922. update_calcs(Fieldnumber%)
  12923.  ic%=icons%-1 
  12924. 3    Fieldnumber%=
  12925. next_editable(Fieldnumber%,1)
  12926. .    
  12927.  pressed%=398 
  12928.  ic%+=cols% 
  12929.  ic%+=1
  12930. !    
  12931.  ic%>icons%-1 
  12932.  ic%=col%
  12933. .    
  12934. set_caret(0,wi%,ic%):row%=ic% 
  12935.  cols%
  12936. scroll_it(wi%,row%,
  12937. selected(prefsW%,19) 
  12938. relations
  12939.  399,415:
  12940. *  changed%=
  12941. update_calcs(Fieldnumber%)
  12942.  ic%=0 
  12943. 4    Fieldnumber%=
  12944. next_editable(Fieldnumber%,-1)
  12945. .    
  12946.  pressed%=399 
  12947.  ic%-=cols% 
  12948.  ic%-=1
  12949. '    
  12950.  ic%<0 
  12951.  ic%=icons%-cols%+col%
  12952. .    
  12953. set_caret(0,wi%,ic%):row%=ic% 
  12954.  cols%
  12955. scroll_it(wi%,row%,
  12956. selected(prefsW%,19) 
  12957. relations
  12958.  461:icons%=
  12959. add_row(S%,wi%,row%,cols%):
  12960.  Insert at end (Ins)
  12961.  477:
  12962.  Delete last row if blank (
  12963. D  icons%=
  12964. delete_row(S%,wi%,cols%,Fieldnumber%):ScrollChanged%=
  12965.  493:
  12966.  Insert blank after row with caret (^Ins)
  12967.  ic% 
  12968.  cols%>0
  12969.     ic%-=1
  12970. (  icons%=
  12971. add_row(S%,wi%,row%,cols%)
  12972.  I%=icons%-1 
  12973.  ic%+cols% 
  12974. +    $
  12975. text(wi%,I%)=$
  12976. text(wi%,I%-cols%)
  12977.  I%=ic% 
  12978.  ic%+cols%-1
  12979.     $
  12980. text(wi%,I%)=""
  12981. redraw(wi%)
  12982.   ScrollChanged%=
  12983.  509:
  12984.  Delete row with caret, incl. data (^
  12985.  ic% 
  12986.  cols%>0
  12987.     ic%-=1
  12988.  I%=ic% 
  12989.  icons%-cols%-1
  12990. +    $
  12991. text(wi%,I%)=$
  12992. text(wi%,I%+cols%)
  12993.  I%=icons%-cols% 
  12994.  icons%-1
  12995.     $
  12996. text(wi%,I%)=""
  12997. 3  icons%=
  12998. delete_row(S%,wi%,cols%,Fieldnumber%)
  12999. set_caret(0,wi%,ic%)
  13000. redraw(wi%)
  13001.   ScrollChanged%=
  13002.  pressed%>31 
  13003.  pressed%<384 
  13004.     ScrollChanged%=
  13005. 2    
  13006. main_press(mainW%,field%(Fieldnumber%))
  13007. scroll_it(wi%,row%,end%)
  13008.  scrollrow%,lastrow%
  13009. 0!block%=wi%:
  13010.  "Wimp_GetWindowState",,block%
  13011.  scrollrow%=-(block%!24 
  13012. 3lastrow%=((block%!16-block%!8) 
  13013.  44)+scrollrow%
  13014.  row%=lastrow%:block%!24-=44:
  13015.  "Wimp_OpenWindow",,block%
  13016.  row%<scrollrow% 
  13017.  end%=
  13018. 5  block%!24=-row%*44:
  13019.  "Wimp_OpenWindow",,block%
  13020. get_scroller(R%,F%,cols%)
  13021.  b$,S%,L%
  13022. $Rf%(F%)=
  13023. scroller_number(F%)
  13024. blob_path(
  13025. ,$database%,R%,F%,64,b$)
  13026.  L%<0 
  13027.  "OS_CLI","Copy "+$database%+"."+Tag$(F%)+"scroll.Blank "+b$+" ~C~V"
  13028. import_to_scroller(S%,b$)
  13029. import_to_scroller(S%,f$)
  13030.  L%,N%,I%,F,P%,icons%,micons%,fields%,lastrow%,delfrom%,wi%
  13031. abort_scroller:
  13032. wi%=scrollerW%(S%)
  13033. F%=scrolldata%(S%,0)
  13034. Vicons%=scrolldata%(S%,6):
  13035.  Currently available no.of icons. May need more or fewer
  13036. Hmicons%=scrolldata%(S%,5):
  13037.  Minimum no.of icons. Must not have fewer
  13038. cols%=scrolldata%(S%,8)
  13039.  I%=1 
  13040.  cols%
  13041. ;    
  13042. text(wi%,fields%)=
  13043. #F,sclen%(S%,I%-1))
  13044.     fields%+=1
  13045.  fields%=icons% 
  13046. !      lastrow%=icons% 
  13047.  cols%
  13048. 2      icons%=
  13049. add_row(S%,wi%,lastrow%+1,cols%)
  13050.         
  13051. close_file(F)
  13052.  fields%<micons%:delfrom%=micons%:fields%=icons%
  13053.  fields%<icons%:delfrom%=fields%
  13054.  delfrom%>0 
  13055. %    !  
  13056. delete_icons(wi%,delfrom%)
  13057.   icons%=fields%
  13058.   scrolldata%(S%,6)=icons%
  13059.   lastrow%=fields% 
  13060.  cols%
  13061. 2  !block%=wi%:
  13062.  "Wimp_GetWindowState",,block%
  13063. !  block%!8=block%!12-block%!4
  13064. 3  !block%=0:block%!4=-lastrow%*44-2:block%!12=0
  13065.  "Wimp_SetExtent",wi%,block%
  13066. scroll_it(wi%,0,
  13067. redraw(wi%):
  13068. redraw(wi%)
  13069. ScrollChanged%=
  13070. abort_scroller
  13071. close_file(F)
  13072. wimp_error(
  13073. redraw(wi%)
  13074.  Returns max possible space needed
  13075. max_scroller_length(S%,F%,cols%,scrcol%,L%)
  13076.  I%,rows%,max%
  13077. %!#rows%=scrolldata%(S%,7) 
  13078.  cols%
  13079.  I%=1 
  13080.  rows%
  13081. %#?  max%+=
  13082. max_row_length(S%,F%,cols%,scrcol%,L%)+
  13083. (rowterm$)
  13084. =max%-
  13085. (rowterm$)
  13086. max_row_length(S%,F%,cols%,scrcol%,explen%)
  13087.  I%,max%
  13088.  I%=1 
  13089.  cols%
  13090. %*4  
  13091.  I%=scrcol% 
  13092.  L%=explen% 
  13093.  L%=sclen%(S%,I%-1)
  13094.   max%+=L%+
  13095. (cellsep$)
  13096. =max%-
  13097. (cellsep$)
  13098. read_scroller_row(R%,F%,S%,cols%,sh%,s$)
  13099.  L%,LF%,LR%,F$,S$,F,J%,scrcol%
  13100.  "OS_Byte",229,1:
  13101.  "OS_Byte",124
  13102. %2+L%=
  13103. blob_path(
  13104. ,$database%,R%,F%,64,b$)
  13105.  L%>0 
  13106.   scrcol%=scrcol%(S%)
  13107. #F=scroller_ptr%(S%)
  13108.  J%=1 
  13109.  cols%
  13110.  J%=cols% 
  13111.  s$=""
  13112.     F$=
  13113.  F$<>"" 
  13114.       
  13115.  J%=scrcol% 
  13116. %<3        F$=
  13117. expand(F$,link$(F%),L%,SF$,scrcol%)
  13118. %=         
  13119.  L%=sclen%(S%,J%-1)
  13120.       
  13121.       flag%=
  13122. %@0      
  13123.  sh% 
  13124.  S$+=F$+s$ 
  13125.  S$+=
  13126. pad(F$,L%)+s$
  13127. %A        
  13128.     scroller_ptr%(S%)=0
  13129.     pending%(S%)=
  13130. %F        
  13131.     scroller_ptr%(S%)=
  13132.     remaining%=
  13133. close_file(F)
  13134.  pending%(S%)=
  13135.  "OS_Byte",229,0
  13136. print_rest_of_scrollers(R%)
  13137.  Prints remaining parts of scrollable lists in Horizontal format
  13138.  S%,F%,T%,cols%,F$,remaining%,flag%,L%
  13139.   remaining%=
  13140. :flag%=
  13141.  S%=0 
  13142.  Scrollnum%-1
  13143.  pending%(S%) 
  13144.       F%=scrolldata%(S%,0)
  13145. %X!      cols%=scrolldata%(S%,8)
  13146.       N%=scrolldata%(S%,9)
  13147. %Z:      F$=
  13148. read_scroller_row(R%,F%,S%,cols%,
  13149. ,cellsep$)
  13150. %[&      
  13151. store_string(F$,Tab%(N%),
  13152.       
  13153. adjust_width
  13154. %]        
  13155. %_,  
  13156.  flag% 
  13157. store_rec_num(R%):
  13158. end_line
  13159.  remaining%=
  13160.  format$<>"table" 
  13161. finish_scroller_printing(R%,F%,S%,cols%,pos%)
  13162.  Prints scrollable list in Vertical format
  13163.  F$,flag%
  13164.   flag%=
  13165. %i6  F$=
  13166. read_scroller_row(R%,F%,S%,cols%,
  13167. ,cellsep$)
  13168.  flag% 
  13169. end_line
  13170. store_rec_num(R%)
  13171. %m     
  13172. store_string(F$,pos%,
  13173. %n      
  13174.  pending%(S%)=
  13175. write_scroller(R%,F%)
  13176.  b$,L%,S%,I%,F,wi%
  13177.  adjust% 
  13178. scroller_number(F%)
  13179. wi%=scrollerW%(S%)
  13180. %w+L%=
  13181. blob_path(
  13182. ,$database%,R%,F%,64,b$)
  13183.  I%=0 
  13184.  scrolldata%(S%,6)-1
  13185. text(wi%,I%)
  13186. close_file(F)
  13187.  "OS_File",18,b$,&fff
  13188. scroller_number(F%)
  13189.  S%<Scrollnum%-1 
  13190.  scrolldata%(S%,0)<>F%
  13191.   S%+=1
  13192. scroller_num2(wi%)
  13193.  S%<Scrollnum%-1 
  13194.  wi%<>scrollerW%(S%)
  13195.   S%+=1
  13196. kill_scrollers(permanent%)
  13197.  F%,S%,F,f$
  13198. S%=Scrollnum%
  13199.  S%>0
  13200.   S%-=1
  13201. scroll_it(scrollerW%(S%),0,
  13202. close_window(scrollerW%(S%))
  13203.  adjust% 
  13204.  $Reformatted%="" 
  13205.     F%=scrolldata%(S%,0)
  13206. /    f$=$database%+"."+Tag$(F%)+"scroll.Max"
  13207.     F=
  13208.      
  13209. (scrolldata%(S%,7))
  13210. close_file(F)
  13211.  "OS_File",18,f$,&fff
  13212.  permanent% 
  13213.  Scrollnum%=0
  13214. inscroll(F%,col%,s$,op$,val%)
  13215.  len%,found%,cell$,case%,F,N%,cols%,S$
  13216. /len%=
  13217. blob_path(
  13218. ,$database%,REC%,F%,64,b$)
  13219. cols%=chartype%(F%)-63
  13220. case%=
  13221. selected(queryW%,1)
  13222.   cell$=
  13223.   N%+=1:
  13224.  N%>cols% 
  13225.  N%=1
  13226.  N%=col% 
  13227.  col%=0 
  13228. #    
  13229.  case% 
  13230.  cell$=
  13231. u(cell$)
  13232.  op$ 
  13233. %      
  13234.  "{":found%=(
  13235. cell$,s$)>0)
  13236. &      
  13237.  "}{":found%=(
  13238. cell$,s$)=0)
  13239. $      
  13240.  "$":found%=
  13241. wc(cell$,s$)
  13242. ,      
  13243. ":found%=
  13244. wc(cell$,s$)      
  13245.       
  13246.       
  13247.  val% 
  13248. &        
  13249. :S$="VAL(cell$)"+op$+s$
  13250. +        
  13251. :S$="cell$"+op$+""""+s$+""""
  13252.       
  13253.       found%=
  13254.         
  13255.  found% 
  13256. close_file(F)
  13257. =found%
  13258.  ### End of scrollable-list routines ###
  13259. get_winpos
  13260.  F,x%,y%,w%,h%,xs%,ys%,ic%
  13261.  design% 
  13262. (  w%=ScreenWidth%*2:h%=MaxFields%*64
  13263.   x%=0:y%=0:xs%=0:ys%=0
  13264. 4  !block%=0:block%!4=-h%:block%!8=w%:block%!12=0
  13265.  "Wimp_SetExtent",mainW%,block%
  13266. position_window(mainW%,x%,y%,w%,h%,xs%,ys%)
  13267. ($database%+".Winpos")
  13268.  F=0 
  13269. 7    !block%=mainW%:
  13270.  "Wimp_GetWindowState",,block%
  13271. /    
  13272. position_window(mainW%,200,-1,0,0,0,0)
  13273. K    
  13274.  ShowTools% 
  13275.  Tools%=1 
  13276. position_window(keypadW%,100,50,0,0,0,0)
  13277.         
  13278. #F,x%,y%,w%,h%,xs%,ys%
  13279. 4    
  13280. position_window(mainW%,x%,y%,w%,h%,xs%,ys%)
  13281.  ShowTools% 
  13282.       
  13283.  Tools% 
  13284.         
  13285. #        
  13286. #F,x%,y%,w%,h%,xs%,ys%
  13287. :        
  13288. position_window(keypadW%,x%,y%,w%,h%,xs%,ys%)
  13289. 9        
  13290. position_window(keypadW%,100,50,0,0,0,0)
  13291.       
  13292.         
  13293. close_file(F)
  13294. save_winpos
  13295. $database%,4)="CDFS" 
  13296. ($database%+".Winpos")
  13297. save_window(mainW%)
  13298.  Tools%=1 
  13299. save_window(keypadW%)
  13300. #F,650,400,658,316,0,0
  13301. close_file(F)
  13302. save_window(handle%)
  13303.  x%,y%,w%,h%,xs%,ys%,ic%
  13304. 4!block%=handle%:
  13305.  "Wimp_GetWindowState",,block%
  13306. ;x%=block%!4:y%=block%!8:w%=block%!12-x%:h%=block%!16-y%
  13307. xs%=block%!20:ys%=block%!24
  13308. #F,x%,y%,w%,h%,xs%,ys%
  13309. position_window(wi%,x%,y%,w%,h%,xs%,ys%)
  13310.  wi% 
  13311.  matchW%,savesubW%:
  13312. shade(queryW%,4,
  13313. default_query
  13314.  changeW%,moveW%,filterW%:
  13315. shade(queryW%,4,
  13316. default_query
  13317.  "Wimp_GetCaretPosition",,block%
  13318. 0!block%=wi%:
  13319.  "Wimp_GetWindowState",,block%
  13320.  w%=0 
  13321.  w%=block%!12-block%!4
  13322.  h%=0 
  13323.  h%=block%!16-block%!8
  13324.  0:x%=(ScreenWidth%-w%) 
  13325.  -1:x%=block%!4
  13326.  0: y%=(ScreenHeight%-h%) 
  13327.  -1:y%=block%!8
  13328. block%!4=x%:block%!12=x%+w%
  13329. block%!8=y%:block%!16=y%+h%
  13330. block%!20=xs%:block%!24=ys%
  13331. block%!28=-1
  13332.  "Wimp_OpenWindow",,block%
  13333. open_it(wi%)
  13334. default_query
  13335.  f$,d%
  13336. $f$=$database%+".PrintRes.!Query"
  13337.  "OS_File",5,f$ 
  13338.  d%=1 
  13339.  "OS_File",255,f$,Query% 
  13340.  $Query%=""
  13341. open_at(
  13342.  flag%,wi%,butt%,ww%,wh%,iw%,ih%)
  13343.  x%,y%,vxmin%,vymax%,scrollx%,scrolly%
  13344.  flag% 
  13345. 5  !block%=mainW%:
  13346.  "Wimp_GetWindowState",,block%
  13347. L  vxmin%=block%!4:vymax%=block%!16:scrollx%=block%!20:scrolly%=block%!24
  13348. Z  !block%=mainW%:block%!4=field%(buttonfield%(0,butt%)):
  13349.  "Wimp_GetIconState",,block%
  13350. ?  x%=block%!16-scrollx%+vxmin%:y%=block%!20-scrolly%+vymax%
  13351. 2  !block%=wi%:
  13352.  "Wimp_GetWindowState",,block%
  13353. 6  block%!4=x%-(ww%+iw%) 
  13354.  2:block%!12=block%!4+ww%
  13355. 6  block%!8=y%-(wh%+ih%) 
  13356.  2:block%!16=block%!8+wh%
  13357.    block%!28=-1:
  13358. open_it(wi%)
  13359.   flag%=
  13360. open_window(wi%)
  13361. set_up_select(fields%,
  13362.  rows%)
  13363.  S$,I%,J%,Fptr%
  13364. &&ASHselectptr%=
  13365. extend_named_sliding_block(selanchor%,SHclaim%)
  13366. Fptr%=SHselectptr%
  13367.  I%=1 
  13368.  fields%
  13369. &)=  SHselectptr%=
  13370. claim_page(selanchor%,Fptr%-SHselectptr%)
  13371.  chartype%(I%) 
  13372. &+.    
  13373.  3,6,8,46,47,54,56,57,74,75,77,78,79:
  13374. &,"    rows%+=1:
  13375. lit(printM%,5,
  13376. &-W    handle%=
  13377. create_icon(0,numscrollW%,0,-rows%*48,144,48,&17000531,"",Fptr%,-1,15)
  13378. &.9    S$=$
  13379. text(mainW%,desc%(I%)):
  13380. (S$)>8 
  13381. S$,8)
  13382. &/$    $Fptr%=S$:Fptr%+=
  13383. ($Fptr%)+1
  13384. &0Y    handle%=
  13385. create_icon(0,numscrollW%,140,-rows%*48,100,48,&17000531,"",Fptr%,-1,15)
  13386. &1*    $Fptr%=Tag$(I%):Fptr%+=
  13387. ($Fptr%)+1
  13388.  J%=0 
  13389. &3b      handle%=
  13390. create_icon(0,numscrollW%,240+J%*88,-rows%*48,44,44,&0740B13B,"",Fptr%,tick%,1)
  13391.       $Fptr%="":Fptr%+=1
  13392.     calcrow%?I%=rows%
  13393. :calcrow%?I%=0
  13394. &:"!block%=0:block%!4=-rows%*48-4
  13395. block%!8=740:block%!12=0
  13396.  "Wimp_SetExtent",numscrollW%,block%
  13397. enable_row(R%,on%)
  13398.  R%>0 
  13399.  I%=R%*8-6 
  13400.  R%*8-1
  13401. &C"    
  13402. shade(numscrollW%,I%,on%)
  13403. &D+    
  13404.  on% 
  13405. deselect(numscrollW%,I%)
  13406. save_form(f$)
  13407.  F,I%,xd%,yd%,xf%,yf%,w%,h%,bbox%,char%,dicon%,ficon%,Desc$
  13408.  fields%=0 
  13409. Length%=0
  13410. !block%=mainW%
  13411. #F,fields%
  13412.  I%=1 
  13413.  fields%
  13414.   char%=chartype%(I%)
  13415.  char%=39 
  13416.  len%(I%)=0
  13417. &S(  dicon%=desc%(I%):ficon%=field%(I%)
  13418. &T4  block%!4=dicon%:
  13419.  "Wimp_GetIconState",,block%
  13420. &U   xd%=block%!8:yd%=block%!12
  13421.   Desc$=$(block%!28)
  13422. &W4  block%!4=ficon%:
  13423.  "Wimp_GetIconState",,block%
  13424. &X   xf%=block%!8:yf%=block%!12
  13425. &Y2  w%=block%!16-block%!8:h%=block%!20-block%!12
  13426.   bbox%=(h%<<16)+w%
  13427. &[&  
  13428.  hide%?I%=1 
  13429.  char%=char% 
  13430. &\+  
  13431.  mandatory%?I%=1 
  13432.  char%=char% 
  13433. &]+  
  13434.  displayit%?I%=1 
  13435.  char%=char% 
  13436. &^F  
  13437. #F,Desc$,Tag$(I%),xd%,yd%,xf%,yf%,len%(I%),char%,fix%(I%),bbox%
  13438. &_8  
  13439.  len%(I%)>0 
  13440.  dbtype$="old" 
  13441.  Length%+=len%(I%)+1
  13442.   field$(I%)=""
  13443. close_file(F)
  13444.  "OS_File",18,f$,&7f2
  13445. lit(iconbarM%,3,
  13446. make_empty_index(RA%,key%,Z%)
  13447.  I%,K%,P%,KLM%,S$
  13448.  "Hourglass_On"
  13449. KL%(key%),".")
  13450. KLM%=KL%(key%)+13
  13451. P%=LH%+48+(RA%+1)*KLM%
  13452.  SHkeyptr%(key%)=
  13453. extend_named_sliding_block(keyanchor%(key%),P%)
  13454. keybase%=SHkeyptr%(key%)
  13455. keybase%!0=138
  13456. keybase%!4=
  13457. ($Increment%)
  13458. $date%=
  13459. (1)):
  13460. date(key%)
  13461. keybase%!62=0:keybase%!66=0
  13462. keybase%?70=KL%(key%)
  13463. &tCkeybase%?71=
  13464. selected(keyW%,30):case%(key%)=
  13465. selected(keyW%,30)
  13466. &uGkeybase%?72=
  13467. selected(keyW%,35):incspace%(key%)=
  13468. selected(keyW%,35)
  13469. &vCkeybase%?73=
  13470. selected(keyW%,37):null%(key%)=
  13471. selected(keyW%,37)
  13472.  I%=0 
  13473. &x(  !(keybase%+74+(I%*4))=KW%(key%,I%)
  13474.  I%=0 
  13475.   P%=I%*8+LH%
  13476.   !(keybase%+P%)=-P%
  13477.   !(keybase%+P%+4)=P%
  13478. P%=!keybase%
  13479.  I%=0 
  13480.  RA%-1
  13481.  "Hourglass_Percentage",(I%*100) 
  13482.   !(keybase%+P%)=P%+KLM%
  13483.   !(keybase%+P%+4)=0
  13484.   $(keybase%+P%+8)=S$
  13485. #  !(keybase%+P%+KL%(key%)+9)=I%
  13486.   P%+=KLM%
  13487. !(keybase%+P%)=0
  13488. !(keybase%+P%+4)=0
  13489. $(keybase%+P%+8)=S$
  13490.  !(keybase%+P%+KL%(key%)+9)=0
  13491.  "Hourglass_Off"
  13492. save_recs(f$,RA%)
  13493.  dbasehandle%,I%,J%,zero%,rec$
  13494.  I%=1 
  13495.  fields%
  13496.  len%(I%)=0 
  13497.  zero%+=1
  13498.  rec$=
  13499. fields%-zero%-1,
  13500. (10))
  13501.  "Hourglass_On"
  13502. dbasehandle%=
  13503.  I%=0 
  13504. #dbasehandle%=I%*Length%
  13505. #dbasehandle%,rec$
  13506.  "Hourglass_Percentage",(I%*100) 
  13507. #dbasehandle%=(RA%+1)*Length%
  13508. close_file(dbasehandle%)
  13509.  "OS_File",18,f$,&fff
  13510.  "Hourglass_Off"
  13511. move_records(key%,source%,dest%,top)
  13512.  P%,R%,target$,action$,blobs$,ex%,ptr%,file%,deleted%
  13513. "target$=$Query%:Search$=
  13514. parse
  13515. Title$,"."):Title$=" "+
  13516. Title$,P%+2)
  13517.  I%=1 
  13518. (Title$)
  13519. Title$,I%,1)="," 
  13520. Title$,I%,1)=" "
  13521.  target$="" 
  13522.  MarkedRecs%>0 
  13523.     bit$=Title$+" ,"
  13524.  bit$=" all ,"
  13525.   tail$=""
  13526.  bit$=" ,":tail$="when "+Title$
  13527.  "Wimp_WhichIcon",moveW%,block%,&003F0000,&00210000
  13528. movetype%=!block%
  13529.  movetype% 
  13530.  4:action$=
  13531. msg("Err138,"+bit$+
  13532. (source%)+","+
  13533. (dest%)+","+tail$):
  13534.  Move
  13535.  5:action$=
  13536. msg("Err140,"+bit$+
  13537. (source%)+","+tail$):
  13538. selected(prefsW%,15) 
  13539.  action$+=". "+
  13540. msg("Err141"):
  13541.  Delete
  13542.  6:action$=
  13543. msg("Err139,"+bit$+
  13544. (source%)+","+tail$):dest%=source%:
  13545.  Collect
  13546.  file%=0 
  13547.  movetype% 
  13548. 7    
  13549.  4,5:
  13550.  file%=source% 
  13551.  filemem%(file%,key%)=-1
  13552. 4    
  13553.  dest%<>file% 
  13554.  filemem%(file%,key%)=-1
  13555.  file%
  13556. confirm(action$) 
  13557.  I%=1 
  13558.  fields%
  13559.   V%=chartype%(I%)
  13560.  36,37,38,39,40:
  13561.     blobs$+=
  13562. (I%)+","
  13563.  blobs$<>"" 
  13564.  deleted%=
  13565. ($database%+".Deleted")
  13566.  "Hourglass_On"
  13567. *dbasehandle%=
  13568. ($database%+".Database")
  13569. 8SHmisc%=
  13570. extend_named_sliding_block(tempanchor%,RA%)
  13571. earmark(SHmisc%,
  13572. ,file%,top)
  13573. close_file(dbasehandle%)
  13574.  R%=0 
  13575.  RA%-1
  13576. 6  ex%+=1:
  13577.  "Hourglass_Percentage",(ex%*100) 
  13578.   ptr%=SHmisc%
  13579.   file%=ptr%?R%
  13580.  file%<>255 
  13581.  movetype% 
  13582. N      
  13583.  4,5:
  13584.  file%=source% 
  13585. transfer_record(R%,blobs$):
  13586.  MOVE or DELETE
  13587. G      
  13588.  dest%<>file% 
  13589. transfer_record(R%,blobs$):
  13590.  ACCUMULATE
  13591.         
  13592. close_file(deleted%)
  13593.  "Hourglass_Off"
  13594. asterisk(
  13595. transfer_record(REC%,blobs$)
  13596.  key%,F%,P%,V%
  13597. read(
  13598. ,fields%,
  13599. ,REC%,$database%)
  13600.   top=8*file%+LH%
  13601.   N$=key$(key%)
  13602. delete(N$,key%):date%?file%=1:$Date%(file%)=
  13603. today
  13604.  N$<>"*Failed*" 
  13605.  movetype% 
  13606.       
  13607.       
  13608.  DELETE
  13609. 0      
  13610. selected(prefsW%,15) 
  13611. blank(REC%)
  13612.       
  13613.  blobs$<>""
  13614.         F%=
  13615. (blobs$)
  13616.         P%=
  13617. blobs$,",")
  13618.          blobs$=
  13619. blobs$,P%+1)
  13620.         V%=chartype%(F%)
  13621. 9        
  13622. blob_path(
  13623. ,$database%,REC%,F%,V%,F$)>=0 
  13624. '          
  13625. selected(prefsW%,15) 
  13626. (            
  13627.  "OS_CLI","Delete "+F$
  13628.             
  13629. ,            
  13630.  "OS_CLI","Remove "+F$+"D"
  13631. E            
  13632.  "OS_CLI","Rename "+F$+" "+F$+"D":
  13633. #deleted%,F$+"D"
  13634.           
  13635.         
  13636.       
  13637.       
  13638.       
  13639.  MOVE
  13640.       top=8*dest%+LH%
  13641. F      
  13642. insert(N$,key%,dupwarn%):date%?dest%=1:$Date%(dest%)=
  13643. today
  13644.         
  13645.   key%+=1
  13646.  key%>Keys% 
  13647.  N$="*Failed*"
  13648. export_subset(f$)
  13649.  I%,F,R%,R4%,recs%,ptr%,count%,subtotal%,blobs%,ex%,Z%,len%,source$,dest$,O$,REC%,zero%,remove%,S$
  13650.  R4%<>-1
  13651.  "OS_GBPB",9,$database%,block%,1,R4%,255 
  13652.  ,,S$,,R4%
  13653. ?    
  13654.  "indexes","Menus","PrintRes","ValTables","UserFuncs":
  13655. D    
  13656.  "OS_CLI","Copy "+$database%+"."+S$+" "+f$+"."+S$+" ~C~VR"
  13657. }    
  13658.  "Form","FieldCols","!Run","Link","Data","Calc","Config","UsrSprites","CSVoptions","Preference","Subfiles","Winpos":
  13659. C    
  13660.  "OS_CLI","Copy "+$database%+"."+S$+" "+f$+"."+S$+" ~C~V"
  13661.  "Hourglass_On"
  13662. 8SHmisc%=
  13663. extend_named_sliding_block(tempanchor%,RA%)
  13664. Search$=
  13665. parse
  13666. *dbasehandle%=
  13667. ($database%+".Database")
  13668. earmark(SHmisc%,
  13669. ,file%,top)
  13670. (f$+".Database")
  13671. ptr%=SHmisc%
  13672. %subtotal%=
  13673. count_recs(key%,zero%)
  13674. "blobs%=
  13675. find_blobs($database%)
  13676.  I%=0 
  13677.  RA%-1
  13678.  ptr%?I%<>255 
  13679.     ptr%?count%=ptr%?I%
  13680.     ex%=-1
  13681.  ex%<blobs%
  13682.       ex%+=1:F%=Ext%(ex%)
  13683. =      
  13684. copy_blob($database%,f$,I%,recs%,F%,chartype%(F%))
  13685.         
  13686. <    
  13687. readsmarray(dbasehandle%,I%):
  13688. writesmarray(F,recs%)
  13689.     count%+=1
  13690. :    
  13691.  "Hourglass_Percentage",(count%*100) 
  13692.  subtotal%
  13693.  ex%=0 
  13694.  blobs%
  13695.   F%=Ext%(ex%)
  13696. '##  
  13697.  vtype$(chartype%(F%))="L" 
  13698. '$#    S$=Tag$(F%)+"scroll.Format"
  13699. '%D    
  13700.  "XOS_CLI","Copy "+$database%+"."+S$+" "+f$+"."+S$+" ~C~V"
  13701. '&"    S$=Tag$(F%)+"scroll.Blank"
  13702. ''D    
  13703.  "XOS_CLI","Copy "+$database%+"."+S$+" "+f$+"."+S$+" ~C~V"
  13704. '(     S$=Tag$(F%)+"scroll.Max"
  13705. ')D    
  13706.  "XOS_CLI","Copy "+$database%+"."+S$+" "+f$+"."+S$+" ~C~V"
  13707.  recs%>0 
  13708. '-?  F$()="":
  13709. writesmarray(F,recs%):
  13710. #F=Length%*recs%:recs%-=1
  13711.  K%=0 
  13712.  Keys%
  13713.     KL%(MaxKeys%+1)=KL%(K%)
  13714.  I%=0 
  13715. '1'      KF%(MaxKeys%+1,I%)=KF%(K%,I%)
  13716. '2'      KW%(MaxKeys%+1,I%)=KW%(K%,I%)
  13717. '4-    
  13718. make_empty_index(recs%,MaxKeys%+1,
  13719.  REC%=0 
  13720.  recs%-1
  13721.       
  13722. readsmarray(F,REC%)
  13723.       KEY$=
  13724. key2(K%,1)
  13725.       file%=ptr%?REC%
  13726.       top=8*file%+LH%      
  13727. ':$      
  13728. insert(KEY$,MaxKeys%+1,
  13729. ';6      
  13730.  "Hourglass_Percentage",(REC%*100) 
  13731.  recs%
  13732.  REC%
  13733. '=&    keybase%=SHkeyptr%(MaxKeys%+1)
  13734. '>?    filelength%=
  13735. sliding_block_size(keyanchor%(MaxKeys%+1))
  13736. '?.    
  13737.  K%>0 
  13738.  index$="indexes." 
  13739.  index$=""
  13740. '@T    
  13741.  "OS_File",10,f$+"."+index$+Index$(K%),&7f0,,keybase%,keybase%+filelength%
  13742. 'A,    
  13743. scrap_block(keyanchor%(MaxKeys%+1))
  13744. 'C+  
  13745. softerror(
  13746. leaf(f$),171):remove%=
  13747. close_file(F)
  13748. close_file(dbasehandle%)
  13749.  "OS_File",18,f$+".Database",&fff
  13750. export%=
  13751.  "Hourglass_Off"
  13752. close_it(savesubW%)
  13753.  remove% 
  13754. 'L*  
  13755.  "OS_CLI","Remove "+f$+".Database"
  13756. 'MD  
  13757. write_log(-1,"Subset exported:",
  13758. leaf(f$)+" ("+$Query%+")")
  13759. copy_files(source$,dest$)
  13760.  N%,R4%,S$,S%
  13761.  "OS_CLI","Remove "+dest$+".PrimaryKey"
  13762.  "OS_CLI","Remove "+dest$+".Database"
  13763.  These may not be present but remove if they are
  13764. 'V    N%=-1
  13765.  R4%<>-1
  13766. 'X9  
  13767.  "OS_GBPB",9,source$,block%,1,R4%,255 
  13768.  ,,S$,,R4%
  13769. 'Z?    
  13770.  "indexes","Menus","PrintJobs","PrintRes","ValTables":
  13771. '[D    
  13772.  "OS_CLI","Copy "+source$+"."+S$+" "+dest$+"."+S$+" ~C~VR"
  13773. '\q    
  13774.  "PrimaryKey","Config","UserFuncs","UsrSprites","CSVoptions","Preference","FieldCols","Data","Subfiles":
  13775. ']G    
  13776.  "OS_CLI","Copy "+source$+"."+S$+" "+dest$+"."+S$+" ~C~V"    
  13777. '`    R4%=0
  13778.  R4%<>-1
  13779. 'b9  
  13780.  "OS_GBPB",9,source$,block%,1,R4%,255 
  13781.  ,,S$,,R4%
  13782. S$,4) 
  13783. 'd&    
  13784.  "text","draw","rite","roll":
  13785. 'eD    
  13786.  "OS_CLI","Copy "+source$+"."+S$+" "+dest$+"."+S$+" ~C~VR"
  13787. find_blobs(f$)
  13788.  N%,R4%,S$
  13789. N%=-1:Ext%()=0
  13790.  R4%<>-1
  13791. 'n4  
  13792.  "OS_GBPB",9,f$,block%,1,R4%,255 
  13793.  ,,S$,,R4%
  13794. S$,4) 
  13795. 'p)    
  13796.  "text","draw":tag$=
  13797. (S$)-4)
  13798. 'q(    N%+=1:Ext%(N%)=
  13799. field(X%,tag$,
  13800. 'r)    
  13801.  "rite","roll":tag$=
  13802. (S$)-6)
  13803. 's(    N%+=1:Ext%(N%)=
  13804. field(X%,tag$,
  13805. earmark(ptr%,all%,file%,top)
  13806.  I%,P%
  13807.  I%=0 
  13808.  RA%-1
  13809.   ptr%?I%=255
  13810.  "Hourglass_On"
  13811.  file%=0 
  13812.  all% 
  13813.     top=8*file%+LH%
  13814. !    P%=
  13815. neighbour(key%,top,1)
  13816. ,    
  13817. scan_file("P%<>top",key%,file%,2,1)
  13818.         
  13819. &    
  13820. selected(queryW%,file%+6) 
  13821.       top=8*file%+LH%
  13822. #      P%=
  13823. neighbour(key%,top,1)
  13824. .      
  13825. scan_file("P%<>top",key%,file%,2,1)
  13826.         
  13827.  file%
  13828.  "Hourglass_Off"
  13829. rotate
  13830.  Access% 
  13831. confirm(
  13832. msg("Err49"))=
  13833.  keybase%
  13834.  I%,L%,Z%,Q%,R%,S%,key%
  13835.  key%=0 
  13836.  Keys%
  13837.   keybase%=SHkeyptr%(key%)
  13838.   S%=LH%+40
  13839.   Z%=keybase%!S%
  13840.  I%=S%-8 
  13841.  S%-40 
  13842. )    L%=keybase%!I%:R%=keybase%!(I%+4)
  13843. =    
  13844.  L%>0 
  13845.  keybase%!(I%+8)=L% 
  13846.  keybase%!(I%+8)=-(I%+8)
  13847.  Z%>0 
  13848.  keybase%!(S%-40)=Z% 
  13849.  keybase%!(S%-40)=-(S%-40)
  13850.  I%=S%-40 
  13851.     Q%=I%-8
  13852.  Q%=S%-48 
  13853.  Q%=S%
  13854. !    PR%=
  13855. neighbour(key%,I%,0)
  13856. !    SU%=
  13857. neighbour(key%,I%,1)
  13858. '    
  13859.  PR%>S% 
  13860.  keybase%!(PR%+4)=-I%
  13861. #    
  13862.  SU%>S% 
  13863.  keybase%!SU%=-I%
  13864.  key%
  13865. $date%=
  13866. asterisk(
  13867. write_log(-1,"Subfiles rotated","")
  13868. create_index(key%,warn%)
  13869.  indexing% 
  13870.  printing% 
  13871.  file%,top,P%,KEY$,REC%,val$,zero%,replace%,J%,I%,used$,abort%,Z%
  13872. newkey%=0:f$=""
  13873.  J%=0 
  13874.  keyfield%(J%)>0 
  13875. #    f$+=Tag$(keyfield%(J%))+"+"
  13876.     Z%=
  13877.  I%=0 
  13878. *      
  13879.  keyfield%(J%)=KF%(0,I%) 
  13880. -    
  13881.  used$+=Tag$(keyfield%(J%))+";"
  13882. used$=
  13883. used$)
  13884.  used$<>"" 
  13885.  warn%=
  13886. confirm(
  13887. msg("Err100,"+used$))=
  13888. f$)="+"
  13889. u(f$)
  13890.   newkey%+=1
  13891. u(Index$(newkey%))=f$ 
  13892.  newkey%>Keys%
  13893.  newkey%=key%:
  13894. softerror(f$,106):abort%=
  13895.  newkey%<=Keys%:
  13896.   replace%=
  13897.  warn% 
  13898. confirm(
  13899. msg("Err50,"+f$))=
  13900.  abort%=
  13901.  Keys%=MaxKeys%:
  13902. softerror("subsidiary indexes,"+
  13903. (Keys%)+",Keys",23):abort%=
  13904. :Keys%=newkey%
  13905.  abort% 
  13906. copy_keydata(newkey%)
  13907. Index$(newkey%)=f$
  13908. -f$=$database%+".Indexes."+Index$(newkey%)
  13909. make_empty_index(RA%,newkey%,
  13910. lit(iconbarM%,2,
  13911. limit_actions(
  13912. ,multitask%)
  13913. abort_index(f$):
  13914. *dbasehandle%=
  13915. ($database%+".Database")
  13916. indexing%=
  13917. :Search$="TRUE"
  13918. update_stats
  13919.  "Hourglass_On"
  13920.  file%=0 
  13921.   top=file%*8+LH%
  13922.   P%=
  13923. neighbour(key%,top,1)
  13924.   val$=
  13925. type(newkey%)
  13926.  "Hourglass_On"
  13927. scan_file("P%<>top",key%,file%,4,1)
  13928.  file%
  13929.  "Hourglass_Off"
  13930. end_index
  13931. refresh_pointers
  13932. save_keys
  13933. colour(newkey%,2)
  13934. asterisk(
  13935. make_index_menu
  13936. renew_tables
  13937. write_log(-1,"Index "+Index$(newkey%)+" created","")
  13938. refresh_pointers
  13939.  I%=0 
  13940.  Keys%
  13941. #  SHkeyptr%(I%)=!keyanchor%(I%)
  13942. remove_index(name$,rename%)
  13943.  I%,f$,entry$
  13944. Fkey%=0:
  13945. colour(key%,1):
  13946. set_keydata(key%):addr=
  13947. moveto(key%,top,1)
  13948. text(searchW%,3)=Index$(key%):
  13949. redraw_icon(searchW%,3)
  13950. f$=$database%+".Indexes."
  13951.  I%=1 
  13952.  Keys%
  13953.   entry$=Index$(I%)
  13954.  entry$=name$ 
  13955.     Index$(I%)=""
  13956.  rename% 
  13957. .      
  13958.  "OS_File",5,f$+"Del_"+entry$ 
  13959. =      
  13960.  d%=1 
  13961.  "OS_CLI","Remove "+f$+"Del_"+entry$    
  13962. =      
  13963.  "OS_CLI","Rename "+f$+name$+" "+f$+"Del_"+entry$
  13964. *      
  13965.  "OS_CLI","Remove "+f$+name$
  13966.         
  13967. colour(I%,3)
  13968. make_index_menu
  13969. renew_tables
  13970. make_index_menu
  13971.  ptr%,menu$,I%
  13972. "menu_ptr%=
  13973. clear_dynamic_menus
  13974. ptr%=menu_ptr%
  13975.  Keys%>0 
  13976.   menu$="indexes,"
  13977.  I%=1 
  13978.  Keys%
  13979. E    
  13980.  hide%?KF%(I%,0)<>1 
  13981.  Index$(I%)<>"" 
  13982.  menu$+=Index$(I%)+","
  13983.   menu$=
  13984. menu$)
  13985.  menu$<>"indexes" 
  13986. ,    indexesM%=
  13987. create_menu(ptr%,menu$)  
  13988. :    ptr%=indexM%+52:ptr%!4=indexesM%:
  13989. lit(indexM%,1,
  13990. 5    
  13991.  ptr%=indexM%+52:ptr%!4=-1:
  13992. lit(indexM%,1,
  13993. abort_index(f$)
  13994. end_index
  13995.  replace% 
  13996. load_index(f$,newkey%,
  13997.  index%=newkey% 
  13998.  Keys%
  13999. )    Index$(newkey%)=Index$(newkey%+1)
  14000.  index%
  14001. ( '  
  14002. scrap_block(keyanchor%(newkey%))
  14003.   Keys%-=1
  14004.   newkey%=0
  14005. softerror("",43)
  14006. wimp_error(
  14007. end_index
  14008.  "Hourglass_Smash"
  14009. indexing%=
  14010. limit_actions(Access%,multitask%)
  14011.  "Wimp_CreateMenu",,-1
  14012. lit(iconbarM%,2,Modify%)
  14013. close_file(dbasehandle%)
  14014. shift(t%,k%,m%)
  14015.  a%,key%,fi%,I%,F$,action$,finished%,fail%
  14016.  Access% 
  14017. =addr
  14018.  key$(0)="" 
  14019. =addr
  14020.  REC%=RA% 
  14021. =addr
  14022.  t%=0 
  14023.  m%=1 
  14024. confirm(
  14025. msg("Err51"))=
  14026. =addr
  14027.   N$=key$(key%)
  14028. delete(N$,key%)
  14029. (<:  
  14030.  key%=k% 
  14031. next_match(addr,1,Filter$,finished%)
  14032. (=   
  14033.  t%=1 
  14034.  fi%=(file%+1) 
  14035. (>)  
  14036.  t%=-1 
  14037.  fi%=(file%-1-6*(file%=0))
  14038.   top=8*fi%+LH%
  14039.  I%=1 
  14040.  fields%
  14041.       V%=chartype%(I%)
  14042.       
  14043. (E)        
  14044.  36,37,38,39,40,64,65,66,67:
  14045. (FR        
  14046. blob_path(
  14047. ,$database%,REC%,I%,V%,F$)>=0 
  14048.  "OS_CLI","Delete "+F$
  14049.       
  14050. (J@    
  14051. insert(N$,key%,dupwarn%):date%?fi%=1:$Date%(fi%)=
  14052. today
  14053.   top=8*file%+LH%
  14054.   date%?file%=1
  14055.   $Date%(file%)=
  14056. today
  14057.   key%+=1
  14058.  key%>Keys% 
  14059.  N$="*Failed*"
  14060.  N$="*Failed*" 
  14061. =addr
  14062. selected(prefsW%,15) 
  14063. blank(REC%)
  14064. (V&    action$=" Deleted and blanked"
  14065.  action$=" Deleted"
  14066. (Y'  
  14067. :action$=" ===> subfile "+
  14068. (fi%)
  14069. asterisk(
  14070. write_log(REC%,logentry$+action$,"")
  14071. blank(REC%)
  14072.  dbasehandle%
  14073. (a*dbasehandle%=
  14074. ($database%+".Database")
  14075. (b,F$()="":
  14076. writesmarray(dbasehandle%,REC%)
  14077. close_file(dbasehandle%)
  14078. type(key%)
  14079.  F%,V$
  14080.  key%>=0 
  14081.  F%=KF%(key%,0) 
  14082.  F%=-key%
  14083.  chartype%(F%) 
  14084. (j2  
  14085.  3,6,46,47,54,56,57,74,75,77,78,79:V$="VAL"
  14086. getscreensize(
  14087.  S_Width%,
  14088.  S_Height%,
  14089.  Vpix%)
  14090.  H1%,V1%,H2%,V2%,End%
  14091. (p$H1%=0:V1%=4:H2%=8:V2%=12:End%=16
  14092. (q9Mi%!H1%=4:Mi%!V1%=5:Mi%!H2%=11:Mi%!V2%=12:Mi%!End%=-1
  14093.  "OS_ReadVduVariables",Mi%,Mo%
  14094. (s)S_Width%=(1<<(Mo%!H1%))*((Mo%!H2%)+1)
  14095. (t*S_Height%=(1<<(Mo%!V1%))*((Mo%!V2%)+1)
  14096. Vpix%=Mo%!V2%+1
  14097. match(X%,Y%)
  14098. check_record 
  14099. deselect(matchW%,
  14100. selected_esg(matchW%,1))
  14101. select(matchW%,8):$
  14102. text(matchW%,0)="Print"
  14103. text(queryW%,5)="":
  14104. redraw_icon(queryW%,5)
  14105. shade(matchW%,4,
  14106. shade(matchW%,6,
  14107. shade(matchW%,12,
  14108. shade(matchW%,7,printorder$<>"")
  14109. lit(printM%,9,printorder$<>"")
  14110.  QBE% 
  14111. set_dest_sprite
  14112. position_window(matchW%,X%,Y%,0,0,0,0)
  14113. set_caret(0,queryW%,0)
  14114.  Match_tag%>0 
  14115. text(helpW%,0)=Tag$(Match_tag%) 
  14116. text(helpW%,0)=""
  14117. $  fieldsM%=
  14118. field_menu(items%,1)
  14119. tick_one(fieldsM%,0,fields%-1,Match_tag%-1)
  14120. redraw_icon(helpW%,0)
  14121.  Ecalc% 
  14122. !    
  14123. text(matchW%,13)=""
  14124. '    
  14125. text(matchW%,13)="1 calc"
  14126. /    
  14127. text(matchW%,13)=
  14128. (Ecalc%)+" calcs"
  14129. redraw_icon(matchW%,13)
  14130. select(matchW%,2):
  14131. mouse(0,0,4,matchW%,2)
  14132. matching%=
  14133.  List printing -----------------------------------------------------
  14134. do_it(Search$,displayed%)
  14135.  printing% 
  14136.  zero%,P%,rec%,copy%,sel$,default%,matchopt%,stime%,sorton%,concatenations%
  14137.  Sum(),S$(),f%()
  14138.  Sum(numericfields%,5),S$(5),f%(5)
  14139. 2S$()="Items","Sum","Mean","StdDev","Max","Min"
  14140. wimp_error(
  14141. &matchopt%=
  14142. selected_esg(matchW%,1)
  14143. printed%=0
  14144.  matchopt%=8 
  14145. print_init("")
  14146.  printorder$="" 
  14147. .    sel$=$database%+".PrintRes.!Selection"
  14148. &    
  14149.  "OS_File",5,sel$ 
  14150.  default%
  14151.  default%=0 
  14152.       
  14153.  W%=0 
  14154.         F%=KF%(0,W%)
  14155.         
  14156.  F%>0 
  14157. T          F$=
  14158. ~(F%):
  14159. (F$)=1 
  14160.  F$="0"+F$:
  14161. printorder$,F$)=0 
  14162.  printorder$+=F$
  14163. p          
  14164. select(mainW%,field%(F%)):
  14165. lit(printM%,7,
  14166. lit(printM%,8,
  14167. lit(mainM%,7,
  14168. selected(passW%,13))
  14169.         
  14170.       
  14171.       default%=1
  14172. !      
  14173. load_selection(sel$)
  14174.         
  14175.   Form$=printorder$
  14176.   PrintFields%=
  14177. (Form$) 
  14178.  format$="label" 
  14179. (    lablines%=labdepth% 
  14180.  linedepth%
  14181. $    
  14182.  fixed1$<>"" 
  14183.  lablines%-=1
  14184. $    
  14185.  fixed2$<>"" 
  14186.  lablines%-=1
  14187. >    
  14188. selected(printerW%,41) 
  14189.  lablines%-=1:
  14190.  Include key
  14191.  I%=1 
  14192. (Form$)-1 
  14193.       F$=
  14194. Form$,I%,2)
  14195.       F%=
  14196. ("&"+F$)
  14197. -      
  14198.  (F% 
  14199.  128)>0 
  14200.  concatenations%+=1
  14201. !    
  14202. abort_report:
  14203. ]    
  14204.  (PrintFields%-concatenations%)>lablines% 
  14205.  moan_err%,
  14206. msg("Err181,"+
  14207. (lablines%))
  14208. %  Heading$="":Hlongest%=0:Sum()=0
  14209.  numericfields%>0 
  14210.  I%=1 
  14211.  numericfields%
  14212.       Sum(I%,5)=10^30
  14213. include_fields:
  14214.  LenLine% is defined in this procedure
  14215.   TextPtr%=!textanchor%
  14216. list_head
  14217.  Error lines moved from here
  14218. abort_report:
  14219.  "Wimp_GetPointerInfo",,block%
  14220. limit_actions(
  14221. ,multitask%)
  14222. lit(iconbarM%,2,0)
  14223. printing%=
  14224.  "OS_ReadMonotonicTime" 
  14225.  stime%
  14226.  ON ERROR statement was originally here
  14227. *dbasehandle%=
  14228. ($database%+".Database")
  14229. !direc%=
  14230. selected(queryW%,4)+1
  14231.  "Hourglass_On"
  14232.  displayed%>=0:
  14233. readsmarray(dbasehandle%,displayed%)
  14234. print_record(displayed%,addr)
  14235.   printed%=1
  14236.  usekey%=-1:
  14237. text(queryW%,5)="":
  14238. redraw_icon(queryW%,5)
  14239. scan_marked_subfiles("P%<>top",key%,1,direc%,
  14240. text(queryW%,5)=
  14241. (usekey%):
  14242. redraw_icon(queryW%,5)
  14243. complete(1)
  14244. scan_marked_subfiles("P%<>top AND LEFT$(k$,kl%)=useval$",usekey%,1,1,
  14245. end_printing
  14246. abort_report
  14247.  reportdest$="Printer" 
  14248.  printhandle%>0 
  14249. *    
  14250.  "PDriver_AbortJob",printhandle%
  14251. !    
  14252. close_file(printhandle%)
  14253. close_it(informW%)
  14254.  "Hourglass_Smash"
  14255.   reportdest$=""
  14256. lose_fonts
  14257.  printing% 
  14258. end_printing
  14259. close_file(dbasehandle%)
  14260. softerror("",29)
  14261. wimp_error(
  14262. end_printing
  14263.  time%,batch%,rem%
  14264.  matchopt% 
  14265. text(matchW%,13)=
  14266. (printed%)+" found":
  14267.  Count
  14268.  Print
  14269.  printed%=0 
  14270. empty_list
  14271.  format$ 
  14272.  "horiz":
  14273. 2    
  14274.  displayed%=-1 
  14275. total_list:
  14276. page_number
  14277.     SHrecptr%=!recanchor%
  14278. 0    
  14279.  shrink% 
  14280. remove_white_space(format$)
  14281. add_spacers(Count%)
  14282.  "table":
  14283. )    #    
  14284. blank_lines(tabextrarows%)
  14285.      
  14286. total_list:
  14287. page_number
  14288.  "vert":
  14289. 2    
  14290.  displayed%=-1 
  14291. total_list:
  14292. page_number
  14293. 4    
  14294.  shrink% 
  14295. remove_white_space(format$)    
  14296.  "OS_ReadMonotonicTime" 
  14297.  etime%
  14298.   time%=etime%-stime%
  14299. text(matchW%,13)=
  14300. (time% 
  14301.  100)+"."+
  14302. (time% 
  14303.  100)+" sec" 
  14304.  reportdest$ 
  14305.  "Window":
  14306. .    
  14307. selected(printW%,47) 
  14308.  z%=1 
  14309.  z%=-1
  14310. ,    
  14311.  sorton%>0 
  14312. sort_list(sorton%,z%)
  14313. screen_list
  14314.  "File":
  14315. .    
  14316. selected(printW%,47) 
  14317.  z%=1 
  14318.  z%=-1
  14319. 0    
  14320.  sorton%>0 
  14321. sort_list(sorton%,z%)    
  14322. =    
  14323.  "OS_GBPB",2,texthandle%,SHtextptr%,Count%*LenLine%
  14324.      
  14325. close_file(texthandle%)
  14326. lose_list
  14327. close_window(saveW%)
  14328.     savetofile%=
  14329.  "Printer":
  14330. ) "    
  14331.  Count%>0 
  14332.  labcount%>0 
  14333.       
  14334.  sorton%>0 
  14335. )"2        
  14336. selected(printW%,47) 
  14337.  z%=1 
  14338.  z%=-1
  14339. )#"        
  14340. sort_list(sorton%,z%)
  14341.         I%=0:rem%=Count%
  14342. )%,        batch%=pagelength%*printcolumns%
  14343.         
  14344.  rem%>batch%
  14345. )'+          
  14346. direct_print(I%,I%+batch%-1)
  14347. )(%          I%+=batch%:rem%-=batch%
  14348.         
  14349. )*'        
  14350. direct_print(I%,I%+rem%-1)
  14351. )+'        
  14352. direct_print(0,Count%-1)
  14353.       
  14354. )-        
  14355. ).(    
  14356.  "PDriver_EndJob",printhandle%
  14357. )/!    
  14358. close_file(printhandle%)
  14359. )0.    
  14360.  SYS "PDriver_SelectJob",previousjob%
  14361. lose_fonts
  14362.  Output%=2 
  14363.       
  14364. inform("",194,0)
  14365. )4M      
  14366.  "OS_CLI","Copy <Wimp$ScrapDir>.Printers.PBreport printer: ~CF~V"
  14367. )5@      
  14368.  "OS_CLI","Remove <Wimp$ScrapDir>.Printers.PBreport"
  14369.       
  14370. close_it(informW%)
  14371. )7        
  14372. )9(  
  14373. limit_actions(Access%,multitask%)
  14374. ):2  $
  14375. text(queryW%,5)="":
  14376. redraw_icon(queryW%,5)
  14377. );%  
  14378.  default%=1 
  14379. clear_selection
  14380.  9,10:
  14381.  Mark, Clear
  14382. )=-  $
  14383. text(matchW%,13)=
  14384. (printed%)+" found"
  14385. )>-  
  14386. set_icon(markW%,0,(SHmarkptr%?REC%=1))
  14387. close_file(dbasehandle%)
  14388. redraw_icon(matchW%,13)
  14389. lit(iconbarM%,2,Modify%)
  14390. warn_of_marks
  14391.  "Hourglass_Off"
  14392. printing%=
  14393. write_log(-1,"Report printed: "+query$,"")
  14394. remove_white_space(format$)
  14395.  I%,L%,N%,R%,Ls%,line%,LenLine2%,blank$
  14396. Tab2%()=Tab%()
  14397.  format$ 
  14398.  "horiz","table":
  14399. )N"  diff%()=maxlen%()-truelen%()
  14400.   Ls%=
  14401. (spacer$)
  14402.   N%=1
  14403.   last%=
  14404. (Form$)-1
  14405.  I%=1 
  14406.  last% 
  14407.     N%+=1
  14408.     F%=
  14409. fnum(
  14410. Form$,I%,2))
  14411.     L%+=diff%(F%)
  14412. )V.    Tab2%(N%)=truelen%(F%)+Tab2%(N%-1)+Ls%
  14413.   LenLine2%=LenLine%-L%
  14414.  "vert":
  14415. )Z?  
  14416.  Tab2%(2)+TextLine%>Tab%(3) 
  14417.  Tab%(3)=Tab2%(2)+TextLine%
  14418.   LenLine2%=Tab%(3)+2
  14419.  LenLine2%<maxhead%+3 
  14420.   LenLine2%=maxhead%+3
  14421. )_'  blank$=
  14422. maxhead%-Tab2%(N%)+2," ")
  14423. TextPtr%=SHtextptr%
  14424. TextPtr2%=TextPtr%
  14425.  line%=0 
  14426.  Count%-1
  14427.  format$ 
  14428.  "horiz","table":
  14429.     R%=SHrecptr%!(line%*4)
  14430.  R%=-2 
  14431. )hP      
  14432.  "Wimp_TransferBlock",mytask%,TextPtr%,mytask%,TextPtr2%,LenLine2%-1
  14433.       
  14434. shrink
  14435. )j        
  14436.  "vert":
  14437. )lN    
  14438.  "Wimp_TransferBlock",mytask%,TextPtr%,mytask%,TextPtr2%,LenLine2%-1
  14439. )n   TextPtr2%?(LenLine2%-2)=32
  14440. )o   TextPtr2%?(LenLine2%-1)=10
  14441.   TextPtr2%+=LenLine2%
  14442.   TextPtr%+=LenLine%
  14443.  line%
  14444. Tab%()=Tab2%()
  14445. LenLine%=LenLine2%
  14446. TextPtr%=!textanchor%
  14447. )vGSHtextptr%=
  14448. extend_named_sliding_block(textanchor%,Count%*LenLine%)
  14449. SHrecptr%=!recanchor%
  14450. shrink%=
  14451. shrink
  14452.  I%=0 
  14453.  N%-1
  14454.   from%=TextPtr%+Tab%(I%)
  14455.   to%=TextPtr2%+Tab2%(I%)
  14456.    bytes%=Tab%(I%+1)-Tab%(I%)
  14457.  "Wimp_TransferBlock",mytask%,from%,mytask%,to%,bytes%
  14458. #$(TextPtr2%+Tab2%(N%)-1)=blank$
  14459. add_spacers(N%)
  14460.  B%,I%,L%,P%,T%,fields%,sp$
  14461.  vrules% 
  14462. (spacer$)
  14463.  spacer$=
  14464. L%," ") 
  14465. TextPtr%=SHtextptr%
  14466. fields%=
  14467. (Form$) 
  14468. spacer$)):
  14469.  PROCstore_string will overwrite character after
  14470.  spacer with a space. Use shortened spacer (sp$) & poke final character
  14471.  in afterwards.
  14472. *T%=Tab%(1):Tab%()=Tab%()-L%:Tab%(1)=T%
  14473. spacer$)
  14474.     L%-=1
  14475. selected(printW%,29) 
  14476.  N%-=2 
  14477.  N%-=1
  14478.  I%=1 
  14479.  SHrecptr%!(I%*4) 
  14480. A    
  14481.  -2,-3:
  14482.  No spacer added for header,footer & ruler lines
  14483.  J%=2 
  14484.  fields%
  14485. #      P%=(I%*LenLine%)+Tab%(J%)
  14486. !      
  14487. store_string(sp$,P%,
  14488.       TextPtr%?(P%+L%)=B%
  14489. print_record(REC%,address%)
  14490.  I%,F%,S%,N%,V%,Z%,F$,SF$,Tab%,n$,y$,pos%,length%,recdepth%,countpos%,last%,lf%,flag%,scrcol%,sp$,colprt%
  14491.  format$="label" 
  14492.   labcount%+=1:labfield%=1
  14493. selected(printerW%,41) 
  14494.  Label$(labcount%,0)=
  14495. key2(0,1)
  14496. "scroller_ptr%()=0:pending%()=
  14497. %countpos%=Count%:last%=
  14498. (Form$)-1
  14499. pos%=Tab%(1)
  14500.  I%=1 
  14501.  last% 
  14502.  I%<last% 
  14503.  sp$=spacer$ 
  14504.  sp$=""
  14505.   F%=
  14506. fnum(
  14507. Form$,I%,2))
  14508.   N%+=1
  14509. >    
  14510.  0:F$=
  14511. (REC%):
  14512.  format$<>"vert" 
  14513. (F$)," ")+F$
  14514. J    
  14515.  MaxFields%+1:Z%=
  14516. rec_no(F$,key%,address%):F$=
  14517. stripright(F$,"#")
  14518. D    
  14519.  MaxFields%+2:F$=
  14520. (file%):
  14521.  format$<>"vert" 
  14522. 6," ")+F$
  14523.      
  14524. selected(printW%,5) 
  14525. 7      F$=
  14526. expand(F$(F%),link$(F%),Len%,SF$,scrcol%)
  14527. %      
  14528.  F$=F$(F%):Len%=len%(F%)+2
  14529.         
  14530.     V%=chartype%(F%)
  14531. !    
  14532.  V%<>36 
  14533.  V%<>39 
  14534.  lf%=
  14535.       
  14536.  254,255:
  14537.       
  14538. `      
  14539. calc_error(F$,F%,ephemera$(C%,0),ephemera$(C%,1)):
  14540.  moan_err%,
  14541. msg("Err29")
  14542.       C%=F%-MaxFields%-3
  14543.       F$=
  14544. (ephemera$(C%,1))
  14545. &      
  14546.  V%=254 
  14547.  format$<>"vert" 
  14548. '        F$=
  14549. justify(F$,N%+1,N%,sp$)
  14550. )        
  14551.  PROCsums(F$,calcrow%?F%,V%)
  14552.       
  14553.       
  14554.       
  14555.       
  14556.  41,42,43,61,62:
  14557.       Z%=
  14558. no_yes(F%,F$)
  14559. 0      
  14560.  3,6,8,46,47,54,56,57,74,75,77,78,79:
  14561.       
  14562.  format$<>"vert" 
  14563. '        F$=
  14564. justify(F$,N%+1,N%,sp$)
  14565. $        
  14566. sums(F$,calcrow%?F%,V%)
  14567.       
  14568.      
  14569. 9      
  14570.  format$<>"vert" 
  14571. justify(F$,N%+1,N%,sp$)
  14572.       
  14573.  64,65,66,67:
  14574. !      S%=
  14575. scroller_number(F%)
  14576.        pending%(S%)=
  14577. :flag%=
  14578. Z      
  14579.  ScrollForm$="C" 
  14580.  colprt%=
  14581. read_scroller_row(REC%,F%,S%,V%-63,
  14582. ,cellsep$)
  14583.         
  14584. selected(printW%,6) 
  14585. u(F$)
  14586.  format$ 
  14587.  "horiz","table":
  14588.       
  14589.  64,65,66,67:
  14590.       
  14591.  ScrollForm$="R" 
  14592. /        
  14593. print_scroller_as_row(Tab%(N%),N%)
  14594.         
  14595. (        
  14596. store_string(F$,Tab%(N%),
  14597. 5        
  14598. (F$)>truelen%(F%) 
  14599.  truelen%(F%)=
  14600.         
  14601. adjust_width
  14602.       
  14603.       
  14604. &      
  14605. store_string(F$,Tab%(N%),
  14606. 3      
  14607. (F$)>truelen%(F%) 
  14608.  truelen%(F%)=
  14609.       
  14610. adjust_width
  14611.         
  14612.  "vert":
  14613. &    
  14614.  lf% 
  14615. end_line:pos%=Tab%(1)
  14616. %    
  14617. selected_esg(printW%,1) 
  14618. -      
  14619.  1:Head$=Tag$(F%):tail$=":"+
  14620. (160)
  14621. ?      
  14622.  2:Head$=$
  14623. text(mainW%,(desc%(F%))):tail$=":"+
  14624. (160)
  14625. $      
  14626.  36:Head$="":tail$=
  14627. (160)
  14628.         
  14629.  pos%=Tab%(1) 
  14630. /      Head$=
  14631. justify(Head$,2,1,tail$)+tail$
  14632. %      
  14633.  Head$=spacer$+Head$+tail$
  14634.         
  14635. 2    
  14636. store_string(Head$,pos%,
  14637. ):pos%+=
  14638. (Head$)
  14639. &      
  14640.  36,39:
  14641. print_memo(REC%,F%)
  14642.       
  14643.  64,65,66,67:
  14644.       
  14645. store_rec_num(REC%)
  14646.       
  14647.  ScrollForm$="R" 
  14648. *        
  14649. print_scroller_as_row(pos%,2)
  14650.         
  14651. .        
  14652.  flag% 
  14653. store_string(F$,pos%,
  14654. 5        
  14655. (F$)+pos%>Tab%(3) 
  14656.  Tab%(3)=
  14657. (F$)+pos%
  14658.       
  14659. K      
  14660.  pending%(S%) 
  14661. finish_scroller_printing(REC%,F%,S%,V%-63,pos%)
  14662.       
  14663.       
  14664. store_rec_num(REC%)
  14665. .      
  14666. store_string(F$,pos%,
  14667. ):pos%+=
  14668. #      
  14669.  reportdest$="Printer" 
  14670. .        w1%=
  14671. how_wide(F$,0,0,bodyfont%,-1)
  14672. (        
  14673.  concat% 
  14674.  w%+=w1% 
  14675.  w%=w1%
  14676. 0        
  14677.  w%>maxlenP%(2) 
  14678.  maxlenP%(2)=w%+32
  14679.       
  14680.         
  14681. %    
  14682.  concat% 
  14683.  I%+1=
  14684. (Form$) 
  14685. '      
  14686.  pos%>Tab%(3) 
  14687.  Tab%(3)=pos%
  14688.       
  14689. end_line
  14690.       pos%=Tab%(1)
  14691.       
  14692.       lf%=
  14693. H      
  14694.  reportdest$="Printer" 
  14695. store_string(
  14696. (160),pos%,
  14697. ):pos%+=1
  14698. *            
  14699.  "label":
  14700. &    S$=Label$(labcount%,labfield%)
  14701. (    
  14702.  S$="" 
  14703.  S$=F$ 
  14704.  S$+=spacer$+F$
  14705.  F%=labsubfor% 
  14706. $      
  14707.  S$="" 
  14708.  S$=F$(labsubst%)
  14709.         
  14710. &    Label$(labcount%,labfield%)=S$
  14711. "    
  14712.  concat% 
  14713.  labfield%+=1
  14714.  format$ 
  14715.  "horiz","table":
  14716. store_rec_num(REC%)
  14717. end_line
  14718.  colprt% 
  14719. D    
  14720. (pending%())<>0 
  14721. print_rest_of_scrollers(REC%) 
  14722.  "vert":
  14723.  "label":
  14724.  labcount%=labpage% 
  14725. direct_print(0,Count%-1)
  14726. recdepth%=Count%-countpos%
  14727.  format$<>"label" 
  14728.  displayed%=-1 
  14729. * ,  
  14730.  Printable%<(recdepth%-2*(page%>0)) 
  14731. *!!    
  14732.  reportdest$="Printer" 
  14733.       pagecolumn%+=1
  14734.       
  14735.  sorton%=0 
  14736. *$P        
  14737.  pagecolumn%=printcolumns% 
  14738. page_number:
  14739. direct_print(0,Count%-1)
  14740. *%F        
  14741.  pagecolumn%=printcolumns% 
  14742. page_number:pagecolumn%=0
  14743.       
  14744.       
  14745. page_number
  14746. *(        
  14747.     Printable%=pagelength%
  14748. **?    
  14749. selected(printW%,4) 
  14750. list_head 
  14751.  header_lines%=0
  14752. adjust_width
  14753.  reportdest$="Printer" 
  14754. *1'  w%=
  14755. how_wide(F$,0,0,bodyfont%,-1)
  14756.   w%+=spacerlen%
  14757. *3)  
  14758.  w%>maxlenP%(N%) 
  14759.  maxlenP%(N%)=w%
  14760. print_scroller_as_row(pos%,N%)
  14761.  L%,P%
  14762. P%=TextPtr%+pos%
  14763.  pending%(S%)
  14764. *;F  F$=
  14765. read_scroller_row(REC%,F%,S%,V%-63,shrinkscroller%,cellsep$)
  14766. *<-  
  14767.  pending%(S%) 
  14768.  F$<>"" 
  14769.  F$+=rowterm$ 
  14770. store_string(F$,pos%,
  14771.   L%+=
  14772.   pos%+=
  14773.  L%>truelen%(F%) 
  14774.  truelen%(F%)=L%
  14775.  format$="vert" 
  14776.  pos%>Tab%(3) 
  14777.  Tab%(3)=pos%
  14778.  reportdest$="Printer" 
  14779. *D)  w%=
  14780. how_wide("",P%,L%,bodyfont%,-1)
  14781.   w%+=spacerlen%
  14782. *F)  
  14783.  w%>maxlenP%(N%) 
  14784.  maxlenP%(N%)=w%
  14785. page_number
  14786.  line$
  14787. pagenumber%+=1
  14788.  page%>0 
  14789.  Include page numbers
  14790. blank_lines(1)
  14791. store_rec_num(-2)
  14792. *Q6  
  14793. store_string("Page "+
  14794. (pagenumber%),Lmargin%,
  14795. print_memo(R%,F%)
  14796.  F,B%,F$,sp%,L%,LF%,rem$,pos%,Line$,brk%,w%,wh%
  14797.  "OS_Byte",229,1:
  14798.  "OS_Byte",124
  14799. pos%=Tab%(2)
  14800.  reportdest$="Printer" 
  14801.  wh%=
  14802. how_wide(Head$,0,0,headerfont%,-1)
  14803. blob_path(
  14804. ,$database%,R%,F%,36,F$)>=0 
  14805. *]%    Line$=rem$:L%=
  14806. (Line$):brk%=
  14807. *^        
  14808.       B%=
  14809.       Line$+=
  14810. (B%):L%+=1
  14811. *a#      
  14812.  reportdest$="Printer" 
  14813. *b0        w%=
  14814. how_wide(Line$,0,0,bodyfont%,-1)
  14815. *c*        
  14816.  wh%+w%>columnwidth% 
  14817.  brk%=
  14818.       
  14819.       
  14820.  B%=32 
  14821.  sp%=L%
  14822. *f+    
  14823.  B%=10 
  14824.  L%>TextLine% 
  14825.  brk% 
  14826. *h-      
  14827.  B%=10:rem$="":Line$=
  14828. Line$):LF%=
  14829.       
  14830. #F:rem$="":LF%=
  14831. *j8      
  14832. :rem$=
  14833. Line$,sp%+1):Line$=
  14834. Line$,sp%-1):LF%=
  14835. *k        
  14836. store_rec_num(REC%)
  14837. *m%    
  14838. store_string(Line$,pos%,LF%)
  14839. close_file(F)
  14840.  "OS_Byte",229,0
  14841. inmemo(F%,s$)
  14842.  len%,found%,line$,ptr%,case%
  14843. *v*len%=
  14844. load_blob($database%,REC%,F%,36)
  14845.  len%>0 
  14846. *x   case%=
  14847. selected(queryW%,1)
  14848.   ptr%=-1
  14849.     line$=""
  14850. *|        
  14851. *}(      ptr%+=1:line$+=
  14852. (SHmisc%?ptr%)
  14853. *~"    
  14854. (line$)>250 
  14855.  ptr%=len%
  14856. #    
  14857.  case% 
  14858.  line$=
  14859. u(line$)
  14860. *    
  14861.  s$<>"" 
  14862. line$,s$)>0 
  14863.  found%=
  14864.  ptr%=len%
  14865.  s$="" 
  14866.  found%=
  14867. =found%
  14868. wc(f$,t$)
  14869.  failed%,P%,Q%,F%,end%,c$,x$,s$
  14870.  P%+=1
  14871.   c$=
  14872. t$,P%,1)
  14873. (    
  14874.  "":end%=(Q%=F%):failed%=
  14875.  end%
  14876.  $wc%:
  14877.  P%+=1:Q%+=1
  14878.       c$=
  14879. t$,P%,1)
  14880.  c$<>$wc%
  14881.     P%-=1
  14882.  $ws%:
  14883.     R%=P%+1
  14884.  P%+=1
  14885.       c$=
  14886. t$,P%,1)
  14887. #    
  14888.  c$=$ws% 
  14889.  c$=$wc% 
  14890.  c$=""
  14891.       
  14892.  "":end%=
  14893. -      s$=
  14894. t$,R%):failed%=(
  14895. (s$))<>s$)
  14896.       
  14897.  $wc%,$ws%:
  14898. 7      s$=
  14899. t$,R%,P%-R%):Q%=
  14900. f$,s$,Q%):failed%=(Q%=0)
  14901. 9      Q%+=
  14902. (s$)-1:P%-=1:
  14903.  failed% 
  14904.  failed%=(Q%=F%)
  14905.         
  14906.     Q%+=1:x$=
  14907. f$,Q%,1)
  14908.     failed%=(c$<>x$)
  14909.  end% 
  14910.  failed%
  14911.  failed%
  14912. print_labels(x0%,y0%)
  14913.  row%,column%,label%,line%,S$
  14914.  label%=1 
  14915.  labpage%
  14916.  Label$(label%,1)<>"" 
  14917. #    column%=(label%-1) 
  14918.  labup%
  14919.      row%=(label%-1) 
  14920.  labup%
  14921.      x%=x0%+column%*labwidth%
  14922.     y%=y0%-row%*labdepth%
  14923. .    
  14924. print_label_line(fixed1$,headerfont%)
  14925.  line%=1 
  14926.  lablines%
  14927. ;      
  14928. print_label_line(Label$(label%,line%),bodyfont%)
  14929.  line%
  14930. .    
  14931. print_label_line(fixed2$,headerfont%)
  14932. 4    
  14933. print_label_line(Label$(label%,0),keyfont%)
  14934.  label%
  14935. print_label_line(S$,font%)
  14936.  S$<>"" 
  14937.  "ColourTrans_SetFontColours",font%,&ffffff00,0,14
  14938.  "Font_Paint",font%,S$,16,x%,y%
  14939.   y%-=linedepth%
  14940. read_print_options(dest$,wi%,wi2%)
  14941.  S$,extra%,header%,footer%,status%,flags%,ps%
  14942.  dest$="" 
  14943. selected_esg(wi%,4) 
  14944. !    
  14945.  22:reportdest$="Window"
  14946.  23:reportdest$="File"
  14947. "    
  14948.  25:reportdest$="Printer"
  14949. 0    
  14950. printer_driver(Z$) 
  14951.  moan_err%,Z$
  14952. .    
  14953.  "XParallel_Op",0 
  14954.  ,,status%;flags%
  14955.  (flags% 
  14956.  1)=0 
  14957. B      
  14958.  If error flag set hardware is too old to report status
  14959. E      
  14960.  DON'T report printer as 'not ready' - have to trust user!
  14961. J      
  14962.  IF ((status%>>3) AND 1)=0 THEN ERROR moan_err%,FNmsg("Err182")
  14963.  reportdest$="Window"
  14964. selected_esg(wi%,3) 
  14965.  15:format$="horiz"
  14966.  16:format$="vert"
  14967. selected_esg(wi%,6) 
  14968.  40:ScrollForm$="R":shrinkscroller%=
  14969. selected(wi%,43)
  14970.  41:ScrollForm$="C"
  14971. ,cellsep$=
  14972. convert_spacer($
  14973. text(wi%,50))
  14974. ,rowterm$=
  14975. convert_spacer($
  14976. text(wi%,51))
  14977.  usekey%=-1 
  14978.  S$=Index$(key%) 
  14979.  S$=Index$(usekey%)+" index"
  14980. Title1$="Ordered by "+S$
  14981. Title2$=$
  14982. text(wi%,10)
  14983. +spacer$=
  14984. convert_spacer($
  14985. text(wi%,26))
  14986. vplot%=0
  14987. spacer$,"|")>0 
  14988.  vplot%=5
  14989. spacer$,"
  14990. ")>0 
  14991.  vplot%=21
  14992.  vplot%>0 
  14993.  reportdest$ 
  14994.  "Window":vrules%=
  14995.  "File":vrules%=
  14996. >    
  14997.  "Printer":
  14998. (spacer$)<3 
  14999.  spacer$=
  15000. 3," "):vrules%=
  15001.  vrules%=
  15002. )Lmargin%=1:Tab%(0)=0:Tab%(1)=Lmargin%
  15003. Tmargin%=1
  15004. TextLine%=
  15005. text(wi%,18))
  15006.  pagelength%=
  15007. text(wi%,9))
  15008.  pagelength%=0 
  15009.  pagelength%=1000000
  15010. selected(wi%,28) 
  15011.  header%=6 
  15012.  header%=0
  15013. selected(wi%,29) 
  15014.  footer%=3 
  15015.  footer%=0
  15016. selected(wi%,35) 
  15017.  page%=1 
  15018.  page%=0
  15019. pagenumber%=0
  15020. +extra%=2*page%+Tmargin%+header%+footer%
  15021. shrink%=
  15022. selected(wi%,24)
  15023. &colour%=
  15024. get_icon_cols(printW%,53)
  15025. Cheaderwimpcol%=colour% 
  15026.  16:headercol%=wimpcol%(headerwimpcol%)
  15027. &colour%=
  15028. get_icon_cols(printW%,54)
  15029. =bodywimpcol%=colour% 
  15030.  16:bodycol%=wimpcol%(bodywimpcol%)
  15031. &colour%=
  15032. get_icon_cols(printW%,55)
  15033. =rulewimpcol%=colour% 
  15034.  16:rulecol%=wimpcol%(rulewimpcol%)
  15035.  reportdest$="Printer" 
  15036.   pause%=
  15037. selected(wi2%,87)
  15038.   shrink%=
  15039.   Lmargin%=0
  15040.   Tmargin%=0
  15041.   tabextrarows%=0
  15042. selected_esg(wi2%,7) 
  15043.  61:pointsize%=8
  15044.  62:pointsize%=10
  15045.  63:pointsize%=12
  15046.  64:pointsize%=14
  15047. '    
  15048. :pointsize%=
  15049. text(wi2%,65))
  15050. &    
  15051.  pointsize%=0 
  15052.  pointsize%=10
  15053. get_fonts
  15054. +    6  spacerlen%=
  15055. how_wide(spacer$,0,0,headerfont%,-1)
  15056.  spacerlen%<6 
  15057.  spacerlen%=6
  15058. selected_esg(wi2%,1) 
  15059.     orientation$="upright"
  15060. $    Plmargin%=
  15061. convert_to_OS(14)
  15062. $    Prmargin%=
  15063. convert_to_OS(15)
  15064. $    Ptmargin%=
  15065. convert_to_OS(16)
  15066. $    Pbmargin%=
  15067. convert_to_OS(18)
  15068.     orientation$="sideways"
  15069. $    Plmargin%=
  15070. convert_to_OS(16)
  15071. $    Prmargin%=
  15072. convert_to_OS(18)
  15073. $    Ptmargin%=
  15074. convert_to_OS(15)
  15075. (    Pbmargin%=
  15076. convert_to_OS(14)    
  15077. selected_esg(wi2%,9) 
  15078.  80:printcolumns%=1
  15079.  81:printcolumns%=2
  15080.  85:printcolumns%=3
  15081.  86:printcolumns%=4
  15082.  printcolumns%=1 
  15083.  gutter%=0 
  15084.  gutter%=
  15085. convert_to_OS(82)
  15086.  "PDriver_Info" 
  15087.  ,,,n%
  15088. +!=  ps%=((n% 
  15089.  (1<<29)<>0)):
  15090.  Is this a PostScript printer?
  15091.  Output% 
  15092. +#&    
  15093.  1:printhandle%=
  15094. ("printer:")
  15095. +$?    
  15096.  2:printhandle%=
  15097. ("<Wimp$ScrapDir>.Printers.PBreport")
  15098. inform("",193,0)
  15099.  "OS_Byte",229,0
  15100. +(:  
  15101.  "PDriver_SelectJob",printhandle%,0 
  15102.  previousjob%
  15103.  ps% 
  15104. declare_fonts
  15105. +*C  
  15106. get_document_size(left%,bottom%,right%,top%,paperx%,papery%)
  15107. selected(wi2%,68) 
  15108. +,+    
  15109.  Plmargin%>left% 
  15110.  left%=Plmargin%
  15111. +-/    
  15112.  Pbmargin%>bottom% 
  15113.  bottom%=Pbmargin%
  15114. +.=    
  15115.  Prmargin%>paperx%-right% 
  15116.  right%=paperx%-Prmargin%
  15117. +/9    
  15118.  Ptmargin%>papery%-top% 
  15119.  top%=papery%-Ptmargin%
  15120. +1!  leading%=
  15121. text(wi2%,56))
  15122. +2#  
  15123.  leading%<100 
  15124.  leading%=100
  15125. +3+  linedepth%=(pointsize%*leading%) 
  15126.  orientation$ 
  15127. +5=    
  15128.  "upright":pagelength%=(top%-bottom%-8) 
  15129.  linedepth%
  15130. +6O    columnwidth%=(right%-left%-(gutter%*(printcolumns%-1))) 
  15131.  printcolumns%
  15132. +7>    
  15133.  "sideways":pagelength%=(right%-left%-8) 
  15134.  linedepth%
  15135. +8O    columnwidth%=(top%-bottom%-(gutter%*(printcolumns%-1))) 
  15136.  printcolumns%
  15137.   columnwidth%-=12
  15138. +;   copies%=
  15139. text(wi2%,45))
  15140. +<   
  15141. selected_esg(wi2%,2) 
  15142.  7:format$="table"
  15143. +>(    tablecolumns%=
  15144. text(wi2%,23))
  15145. +?,    tablecolumnwidth%=
  15146. convert_to_OS(24)
  15147. +@(    tabextrarows%=
  15148. text(wi2%,69))
  15149.  8:format$="label"
  15150. +B'    Title$="":Title1$="":Title2$=""
  15151. +C"    
  15152. selected_esg(wi2%,5) 
  15153.       
  15154.  28:labup%=1
  15155.       
  15156.  29:labup%=2
  15157.       
  15158.  30:labup%=3
  15159.       
  15160.  53:labup%=4
  15161. +H        
  15162. +I$    labwidth%=
  15163. convert_to_OS(32)
  15164. +J$    labdepth%=
  15165. convert_to_OS(34)
  15166. +K$    labrows%=papery% 
  15167.  labdepth%
  15168. +L     labpage%=labrows%*labup%
  15169. +M<    startlabel%=
  15170. text(wi2%,55))-1:$
  15171. text(wi2%,55)="1"
  15172.     labcount%=startlabel%
  15173. +O"    labsubst%=-1:labsubfor%=-1
  15174. selected(wi2%,39) 
  15175.       S$=$
  15176. text(wi2%,78)
  15177. +R.      
  15178.  S$<>"" 
  15179.  labsubst%=
  15180. field(X%,S$,
  15181.       S$=$
  15182. text(wi2%,40)
  15183. +T/      
  15184.  S$<>"" 
  15185.  labsubfor%=
  15186. field(X%,S$,
  15187. +U        
  15188.     fixed1$=$
  15189. text(wi2%,51)
  15190.     fixed2$=$
  15191. text(wi2%,52)
  15192. convert_spacer(S$)
  15193.  S%,C$
  15194. (S$):C$=
  15195. +`"  
  15196.  S%=0:
  15197.  Use spacer$ "as is"
  15198. +a"  
  15199.  C$<"0" 
  15200.  C$>"9":S$=
  15201. S%,C$)
  15202. S%," ")
  15203. convert_to_OS(ic%)
  15204.  N,units$
  15205. units$=$
  15206. text(printerW%,33)
  15207.  get current units from label, NOT from selected radio button
  15208. text(printerW%,ic%))
  15209.  units$ 
  15210.  "mm":N=N*60*180/1524
  15211.  "in":N=N*180
  15212.  "pt":N=N*180/72
  15213. convert_units
  15214.  units$,P%,S$,factor,ic%,N
  15215.  PROC is only called when radio button clicked. Get NEW units from button
  15216. selected_esg(printerW%,8) 
  15217. +w6  
  15218.  48:units$="mm":factor=60*180/1524:@%=&01020109
  15219. +x.  
  15220.  38:units$="in":factor=180:@%=&01020209
  15221. +y1  
  15222.  77:units$="pt":factor=180/72:@%=&01020109
  15223.  14,15,16,18,24,32,34,82,-1
  15224.  ic%<>-1
  15225. convert_to_OS(ic%)
  15226.   N=N/factor
  15227. text(printerW%,ic%)=
  15228. redraw_icon(printerW%,ic%)
  15229. @%=&90A
  15230. label_units(units$)
  15231. label_units(U$)
  15232.  ic%,S$
  15233.  10,26,33,35,83,-1
  15234.  ic%<>-1
  15235.   S$=$
  15236. text(printerW%,ic%)
  15237. S$)=")" 
  15238. S$,3)=U$+")" 
  15239.  S$=U$
  15240. text(printerW%,ic%)=S$
  15241. redraw_icon(printerW%,ic%)
  15242. list_head
  15243.  exit%
  15244. "hspace%=0:fspace%=0:maxhead%=0
  15245. Printable%=pagelength%
  15246. blank_lines(Tmargin%)
  15247.  format$="label" 
  15248.  header_lines%=Count%:
  15249.  displayed%=-1 
  15250.  Title2$<>"" 
  15251. send_title(Title2$)
  15252. selected(printW%,11) 
  15253. send_title("Printed: "+
  15254. selected(printW%,28) 
  15255.  displayed%=-1 
  15256. send_title(Title$):
  15257. send_title(Title1$)
  15258.  format$ 
  15259.  "horiz":
  15260. (    
  15261. selected_esg(printW%,1)<>36 
  15262. N      
  15263.  "Wimp_TransferBlock",mytask%,SHheadptr%,mytask%,TextPtr%,LenLine%
  15264.       
  15265. store_rec_num(-1)
  15266.       
  15267. end_line
  15268.       
  15269.       hspace%-=90
  15270.       
  15271.  hspace%-=18
  15272.         
  15273.  "vert":
  15274.  "table":
  15275. (    
  15276. selected_esg(printW%,1)<>36 
  15277. N      
  15278.  "Wimp_TransferBlock",mytask%,SHheadptr%,mytask%,TextPtr%,LenLine%
  15279.       
  15280. store_rec_num(-1)
  15281.       
  15282. end_line
  15283.         
  15284.  Count%>Tmargin% 
  15285. rule:hspace%-=18
  15286.  header_lines%=0 
  15287.  header_lines%=Count%
  15288. hspace%+=header_lines%*36
  15289.  displayed%>=0 
  15290.   fspace%=0
  15291.  fspace%=36-
  15292. selected(printW%,29)*54+page%*72
  15293. pad_line(bytes%,char%)
  15294.  base%,ptr%,I%
  15295. /base%=pointer%:ptr%=base%+LenLine%-bytes%-1
  15296.  bytes%>0 
  15297.  I%=0 
  15298.  bytes%-2
  15299.     ptr%?I%=char%
  15300. ptr%?(bytes%-1)=32
  15301. ptr%?bytes%=10
  15302. total_list
  15303.  reportdest$="" 
  15304. selected(printW%,29) 
  15305. blank_lines(1):
  15306. L$="Total "+
  15307. (printed%)
  15308.  format$ 
  15309.  "horiz":
  15310. ctotals(numfirst%)
  15311. store_rec_num(-2)
  15312. store_string(L$,Lmargin%,
  15313.  "vert":
  15314. store_rec_num(-2)
  15315. store_string(L$,Lmargin%,
  15316.  "table":
  15317. ctotals(numfirst%)
  15318. store_rec_num(-2)
  15319. store_string(L$,Lmargin%,
  15320. send_title(T$)
  15321.  C$,L%,max%,Line$,sp%,brk%
  15322. max%=LenLine%-Lmargin%-2
  15323.  T$<>""
  15324.     C$=
  15325. T$,1):T$=
  15326. T$,2)
  15327.     Line$+=C$:L%+=1
  15328. #    
  15329. " ,;:.-=",C$)>0 
  15330.  sp%=L%
  15331.  L%=max% 
  15332.  brk%=
  15333. !    
  15334.  reportdest$="Printer" 
  15335. 0      w%=
  15336. how_wide(Line$,0,0,headerfont%,-1)
  15337. $      
  15338.  w%>columnwidth% 
  15339.  brk%=
  15340.         
  15341.  T$="" 
  15342.  brk%
  15343.  sp%=0 
  15344.  sp%=L%
  15345.  brk% 
  15346. Line$,sp%+1)+T$:Line$=
  15347. Line$,sp%):shrink%=
  15348. store_rec_num(-2)
  15349.  pagecolumn%=0 
  15350. store_string(Line$,Tab%(1),
  15351. end_line
  15352. (Line$)>maxhead% 
  15353.  maxhead%=
  15354. (Line$)
  15355.    Line$="":L%=0:brk%=
  15356. :sp%=0
  15357. store_string(S$,pos%,end%)
  15358. $(TextPtr%+pos%)=S$
  15359. TextPtr%?(pos%+
  15360. (S$))=32
  15361.  end% 
  15362. end_line
  15363. store_rec_num(R%)
  15364. 0SHrecptr%=
  15365. claim_page(recanchor%,Count%*4+4)
  15366. !(SHrecptr%+Count%*4)=R%
  15367. end_line
  15368. TextPtr%?(LenLine%-1)=10
  15369. Count%+=1:Printable%-=1
  15370. ,    ;SHtextptr%=
  15371. claim_page(textanchor%,(Count%+1)*LenLine%)
  15372. TextPtr%+=LenLine%
  15373.  reportdest$<>"Printer" 
  15374.  I%=Lmargin% 
  15375.  LenLine%-3
  15376.     TextPtr%?I%=152
  15377. store_rec_num(-3)
  15378. end_line
  15379. blank_lines(lines%)
  15380.  lines%>0
  15381. store_rec_num(-2)
  15382. end_line
  15383.   lines%-=1
  15384. blank_columns(lines%,pos%,C$)
  15385.  lines%>0
  15386. store_string(C$,pos%,
  15387.   lines%-=1
  15388. screen_list
  15389. SHrecptr%=!recanchor%
  15390. ,)!!block%=0:block%!4=-Count%*36
  15391. ,*(block%!8=(LenLine%-1)*16:block%!12=0
  15392.  "Wimp_SetExtent",listW%,block%
  15393. !block%=listW%
  15394.  "Wimp_GetWindowState",,block%
  15395. ,.;x%=(block%!12+block%!4) 
  15396.  2:y%=(block%!16+block%!8) 
  15397. ,/"block%!12=block%!4+LenLine%*16
  15398.  Count%<28 
  15399. ,1"  block%!16=block%!8+Count%*36
  15400.   block%!16=block%!8+36*28
  15401.  "Wimp_CloseWindow",,block%
  15402. open_window(listW%)
  15403. Listed%=
  15404. lit(listM%,0,
  15405. selected(passW%,13))
  15406. lit(listM%,2,(format$="horiz" 
  15407.  format$="vert") 
  15408.  shrink%)
  15409. sort_textcol%=-1
  15410. $SortTextCol%="Sort   """""
  15411. lit(listM%,1,
  15412. show_menu(listM%,x%,y%)
  15413.  x%+214,y%-20
  15414. sort_list(N%,z%)
  15415.  A%,I%,P%,ind%,type%,L%
  15416.  N%=-1 
  15417. selected(queryW%,1) 
  15418.  type%=5 
  15419.  type%=4
  15420. ,F1SHtextptr%=!textanchor%:SHrecptr%=!recanchor%
  15421. ind%=SHtextptr%+Tab%(N%)
  15422. ,H?SHmisc%=
  15423. extend_named_sliding_block(tempanchor%,Count%*4+4)
  15424. ,I?SHmisc2%=
  15425. extend_named_sliding_block(balanchor%,Count%*4+4)
  15426.  sortfield%>0 
  15427.  L%=len%(sortfield%)
  15428.  I%=0 
  15429.  Count%-1
  15430.  SHrecptr%!(I%*4)<0 
  15431.     SHmisc2%!(I%*4)=ind%
  15432. ,N        
  15433. ,O3    SHmisc2%!(I%*4)=0:SHmisc%!(A%*4)=ind%:A%+=1
  15434.  sortfield%>0 
  15435. ,Q"      byte%=ind%?L%:ind%?L%=13
  15436. ,R)      $ind%=
  15437. transform_date(L%,$ind%)
  15438.       ind%?L%=byte%
  15439. ,T        
  15440.   ind%+=LenLine%  
  15441.  "OS_HeapSort",A%,SHmisc%,type%
  15442. ,YFSHsort%=
  15443. extend_named_sliding_block(sortanchor%,Count%*LenLine%+4)
  15444. ,ZBSHtemprec%=
  15445. extend_named_sliding_block(flaganchor%,Count%*4+4)
  15446. dest%=SHsort%
  15447.  z%=-1 
  15448.  A%-=1 
  15449.  A%=0
  15450.  I%=0 
  15451.  Count%-1
  15452.   ind%=SHmisc2%!(I%*4)
  15453.  ind%=0 
  15454. ,`"    ind%=SHmisc%!(A%*4):A%+=z%
  15455.  sortfield%>0 
  15456. ,b"      byte%=ind%?L%:ind%?L%=13
  15457. ,c)      $ind%=
  15458. transform_date(L%,$ind%)
  15459.       ind%?L%=byte%
  15460. ,gJ  
  15461.  "Wimp_TransferBlock",mytask%,ind%-Tab%(N%),mytask%,dest%,LenLine%
  15462. ,h.  P%=(ind%-Tab%(N%)-SHtextptr%) 
  15463.  LenLine%
  15464. ,i(  SHtemprec%!(I%*4)=SHrecptr%!(P%*4)
  15465.   dest%+=LenLine%
  15466.  "Wimp_TransferBlock",mytask%,SHsort%,mytask%,SHtextptr%,Count%*LenLine%
  15467.  "Wimp_TransferBlock",mytask%,SHtemprec%,mytask%,SHrecptr%,Count%*4
  15468. scrap_block(sortanchor%)
  15469. scrap_block(tempanchor%)
  15470. scrap_block(balanchor%)
  15471. scrap_block(flaganchor%)
  15472. redraw(listW%)
  15473. lose_list
  15474. close_window(listW%)
  15475. scrap_block(headanchor%):SHheadptr%=0
  15476. scrap_block(textanchor%):SHtextptr%=0
  15477. scrap_block(recanchor%):SHrecptr%=0
  15478. Listed%=
  15479. query
  15480.  qbe% 
  15481. parse
  15482.  search$,F$,G$,FT$,F%,X$,P%,Q%,I%,t$,op$
  15483.  F%=1 
  15484.  fields%
  15485.  chartype%(F%) 
  15486.  0,1,2,3,4,63:
  15487.     F$=$Rf%(F%)
  15488.  WHEN 41,42,43:
  15489. 1    
  15490.  IF $Rf%(F%)=" " THEN F$="Y" ELSE F$="N"
  15491.  F$=""
  15492.   G$=F$
  15493.  F$<>"" 
  15494. >    X$=">=>=,<=<=,<>,}{,>=,<=,==,>>,<<,{{,=,<,>,{,~,":P%=0
  15495. (X$)>0 
  15496.  P%=0
  15497. <      Q%=
  15498. X$,","):op$=
  15499. X$,Q%-1):X$=
  15500. X$,Q%+1):P%=
  15501. F$,op$)
  15502.         
  15503.  P%=0 
  15504.  F$="="+F$
  15505. C      
  15506.  G$<>"""" 
  15507.  $Rf%(F%+1)="""":search$+=Tag$(F%)+",":FT$=F$
  15508. B      
  15509.  G$="""" 
  15510.  $Rf%(F%+1)<>"""":search$+=Tag$(F%)+FT$+" & "
  15511. )      
  15512.  G$="""":search$+=Tag$(F%)+","
  15513. &      
  15514. :search$+=Tag$(F%)+F$+" & "
  15515.         
  15516. "$Query%=
  15517. search$,
  15518. (search$)-3)
  15519. parse
  15520. qbe(on%,disp%)
  15521.  on% 
  15522. &  valstatus%=
  15523. selected(prefsW%,21)
  15524. deselect(prefsW%,21):
  15525. val_on_off(
  15526. display(key%,-3)
  15527.  qbe% 
  15528. @    
  15529. set_icon(prefsW%,21,valstatus%):
  15530. val_on_off(valstatus%)
  15531. %    
  15532.  disp% 
  15533. display(key%,addr)
  15534. deselect(matchW%,2)
  15535. qbe%=on%
  15536. parse
  15537.  val%,valt%,vals%,C%,I%,P%,F%,f1%,f2%,t%,flag%,left%,right%,search$,field$,op$,bo$,target$,targ$,f$,t$,tt$,E$,E1$,TitFd$,TitTg$,simple%,date$,SF$,S$,case%,targets%,quoted%,ft%
  15538. S$=$Query%
  15539. u(S$)="ALL" 
  15540.  S$=""
  15541.  S$="" 
  15542.  query$="ALL" 
  15543.  query$=S$ 
  15544. case%=
  15545. selected(queryW%,1)
  15546. usekey%=-1:useval$=""
  15547. stripright(S$," ")
  15548. simple%=
  15549. simple(S$)
  15550.  S$<>"" 
  15551.  S$+=" "
  15552. Title$=""
  15553. (S$)>0
  15554.   W$=
  15555. word(S$," ")
  15556.  W$="NOT" 
  15557. S$,1)<>"(" 
  15558.  moan_err%,
  15559. msg("Err60")
  15560. strip_brackets
  15561. (W$)>0 
  15562.  W$="&" 
  15563.  W$="AND"
  15564. 5    flag%=
  15565. :TitFd$="":TitTg$="":op$="":targets%=0
  15566. 5      
  15567.  "AND","OR","NOT":E$=W$:Title$+=" "+E$+" "
  15568.       
  15569.       E$=""
  15570.       
  15571. split
  15572.       
  15573. (field$)>0
  15574. "        
  15575. field$,"TIME$")=0 
  15576. &          f$=
  15577. word(field$,","))
  15578.           
  15579. field$)
  15580.         
  15581.         f1%=0:f2%=0
  15582.         
  15583. 6          
  15584. f$,"TIME$")>0:TitFd$=f$+" ":field$=""
  15585. <          
  15586.  f$="@":f1%=1:f2%=fields%:TitFd$="Any field "
  15587.           
  15588. f$,"-")>0:
  15589.           P%=
  15590. f$,"-")
  15591. *          f1%=
  15592. field(val%,
  15593. f$,P%-1),
  15594. !          TitFd$=
  15595. TitFd$)+"-"
  15596. *          f2%=
  15597. field(val%,
  15598. f$,P%+1),
  15599. $          
  15600.  f1%>f2% 
  15601.  f1%,f2%
  15602.           
  15603. #          f1%=
  15604. field(val%,f$,
  15605. !          f$="F$("+
  15606. (f1%)+")"
  15607. *          
  15608.  case% 
  15609.  f$="FNu("+f$+")"
  15610. 5          
  15611.  val% 
  15612.  instring% 
  15613.  f$="VAL("+f$+")"
  15614. !          
  15615.  chartype%(f1%) 
  15616.              
  15617.  5,50,51,70,71:
  15618.             L%=len%(f1%)
  15619. 7            f$="FNtransform_date("+
  15620. (L%)+","+f$+")"
  15621.           
  15622.         
  15623.         targ$=target$
  15624.         
  15625. (targ$)>0
  15626.           quoted%=
  15627. :ft%=0
  15628. !          t$=
  15629. word(targ$,",")
  15630.           
  15631.  flag% 
  15632. 4            
  15633.  quoted% 
  15634.  ft%=
  15635. field(valt%,t$,
  15636. E            
  15637.  See whether target is a field rather than a literal
  15638.             
  15639.  ft% 
  15640. ]              
  15641. selected(printW%,37) 
  15642.  tt$=
  15643. expand(t$,link$(f1%),L%,SF$,C%) 
  15644.  tt$=t$
  15645. '              
  15646.  case% 
  15647. u(t$)
  15648.               
  15649. 1              desc$=$
  15650. text(mainW%,desc%(ft%))
  15651. 1              
  15652.  desc$="" 
  15653.  tt$=t$ 
  15654.  tt$=desc$
  15655.                tt$+="(Field)"
  15656. %              t$="F$("+
  15657. (ft%)+")"
  15658. .              
  15659.  case% 
  15660.  t$="FNu("+t$+")"
  15661.             
  15662. -            
  15663.  quoted% 
  15664.  tt$=""""+tt$+""""
  15665.             TitTg$+=tt$+","
  15666.             targets%+=1
  15667.           
  15668.           u$=t$
  15669. !          
  15670.  chartype%(f1%) 
  15671. >            
  15672.  41,42,43,61,62:
  15673.  ft%=0 
  15674. pos_neg(f1%,t$)
  15675. k            
  15676.  5,50,51,70,71:
  15677. check_date(f1%,t$,2,date$)=
  15678. transform_date(len%(f1%),date$):u$=t$
  15679.           
  15680. '          
  15681.  ft%=0 
  15682.  t$=""""+t$+""""
  15683. ?          
  15684.  (val% 
  15685.  valt%) 
  15686.  instring% 
  15687.  t$="VAL("+t$+")"
  15688.           
  15689.  f2%>0 
  15690.             
  15691.  val% 
  15692. T              E1$="FNvany("+
  15693. (f1%)+","+
  15694. (f2%)+","+t$+","""+op$+""","""+bo$+""")"
  15695. U              
  15696.  E1$="FNany("+
  15697. (f1%)+","+
  15698. (f2%)+","+t$+","""+op$+""","""+bo$+""")"
  15699.             
  15700. 6            
  15701.  E1$=
  15702. element(op$,f1%,chartype%(f1%))
  15703.           
  15704. E          
  15705. (E$)+
  15706. (E1$)>255 
  15707.  moan_err%,
  15708. msg("Err6") 
  15709.  E$+=E1$
  15710. E          
  15711. (E$)+
  15712. (bo$)>255 
  15713.  moan_err%,
  15714. msg("Err6") 
  15715.  E$+=bo$
  15716.         
  15717.         flag%=
  15718.       
  15719.       E$=
  15720. (E$)-
  15721. (bo$))
  15722.       
  15723. E$,bo$)>0 
  15724. B        
  15725. (E$)>253 
  15726.  moan_err%,
  15727. msg("Err6") 
  15728.  E$="("+E$+")"
  15729.       
  15730.         
  15731. add_brackets
  15732. (S$)>0 
  15733.  E$+=" "
  15734. (search$)+
  15735. (E$)>255 
  15736.      
  15737.  moan_err%,
  15738. msg("Err6")
  15739.  search$+=E$
  15740. build_title(targets%)
  15741. ,Title$=
  15742. leaf($database%),2)+". "+Title$
  15743.  usekey%>=0 
  15744.  kl%=KL%(usekey%):val$=
  15745. type(usekey%)
  15746.  MarkedRecs%>0 
  15747. selected(matchW%,3) 
  15748. selected(matchW%,8) 
  15749.  filter%=
  15750. ticked(markM%,0):
  15751.  search$="" 
  15752.      search$="base%?REC%=1"
  15753. 8     Title$=
  15754. leaf($database%),2)+". Marked records"
  15755.      
  15756. 1     search$="("+search$+")"+"ORbase%?REC%=1"
  15757.      usekey%=-1:useval$=""
  15758. )     Title$+=" (plus marked records)"
  15759. ticked(markM%,1):
  15760.  search$="" 
  15761.      search$="base%?REC%=0"
  15762. -!:     Title$=
  15763. leaf($database%),2)+". Unmarked records"
  15764.      
  15765. -#2     search$="("+search$+")"+"ANDbase%?REC%=0"
  15766. -$.     Title$+=" (excluding marked records)"
  15767.  search$="" 
  15768.  search$="TRUE":Title$=
  15769. leaf($database%),2)+". All records"
  15770. =search$
  15771. pos_neg(F%,s$)
  15772. u(s$)
  15773.  chartype%(F%) 
  15774.  41,42,43:
  15775. -1C    
  15776.  "Y","YES","T","TRUE","SET","TICKED","
  15777. ","STAR","*":s$=" "
  15778. -2R    
  15779.  "N","NO","F","FALSE","X","CROSS","CLEAR","BLANK","NULL","UNTICKED":s$=""
  15780.  61,62:
  15781. -68    
  15782.  "Y","YES","T","TRUE","SET","TICKED","
  15783. ":s$=" "
  15784. -72    
  15785.  "N","NO","F","FALSE","X","CROSS":s$=
  15786. -8]    
  15787.  "CLEAR","BLANK","NULL","MAYBE","DONTKNOW","DONTCARE","WHAT","WHAT?","EH?","?":s$=""
  15788. simple(S$)
  15789.  flag%
  15790. -@-  
  15791. S$," OR ")>0 
  15792. S$,"NOT ")>0:flag%=
  15793. S$,"==")>0:flag%=
  15794. -B'  
  15795. S$,"=")>0 
  15796. S$,",")=0:flag%=
  15797. =flag%
  15798. word(
  15799.  S$,sep$)
  15800.  P%,Q%,W$
  15801.   P%+=1
  15802. -J   
  15803. S$,P%,1)="""" 
  15804. S$,P%,1)=sep$ 
  15805.  moan_err%,
  15806. msg("Err93")
  15807. S$,P%-1)
  15808. S$,P%+1)
  15809. W$,1)="""" 
  15810. W$)="""" 
  15811. W$,2)):quoted%=
  15812. element(op$,f%,char%)
  15813.  E$,fn$
  15814.  char% 
  15815.  36,39:
  15816.   fn$="FNinmemo("
  15817.  op$ 
  15818. -X+    
  15819.  "{":E$=fn$+
  15820. (f%)+","+t$+")=TRUE "
  15821. -Y1    
  15822.  "}{":E$=fn$+
  15823. (f%)+","+t$+")=FALSE "    
  15824.  "=":
  15825. -[O    
  15826.  t$="""""" 
  15827.  E$=fn$+
  15828. (f%)+","+t$+")=TRUE " 
  15829.  moan_err%,
  15830. msg("Err40")
  15831.  "<>":
  15832. -]P    
  15833.  t$="""""" 
  15834.  E$=fn$+
  15835. (f%)+","+t$+")=FALSE " 
  15836.  moan_err%,
  15837. msg("Err40")
  15838.  64,65,66,67:
  15839. -`R  E$="FNinscroll("+
  15840. (f%)+","+Scrcol$+","+t$+","""+op$+""","+
  15841. (vals%)+")=TRUE "
  15842.  op$ 
  15843. -c)    
  15844.  "{":E$="INSTR("+f$+","+t$+")>0"
  15845. -d*    
  15846.  "}{":E$="INSTR("+f$+","+t$+")=0"
  15847.  "=":
  15848.     E$=f$+op$+t$
  15849. -g"    
  15850.  simple%=
  15851.  usekey%=-1 
  15852. -h!      foundkey%=
  15853. is_a_key(f%)
  15854.       
  15855.  foundkey%>0 
  15856. -j]        
  15857.  KL%(foundkey%)=len%(f%) 
  15858.  case%=case%(foundkey%) 
  15859.  usekey%=foundkey%:useval$=u$
  15860.       
  15861. -l        
  15862. -m,    
  15863.  "$":E$="FNwc("+f$+","+t$+")=TRUE "
  15864. -n-    
  15865. ":E$="FNwc("+f$+","+t$+")=FALSE "
  15866. :E$=f$+op$+t$
  15867. vany(from%,to%,t%,op$,bo$)
  15868.  F%,found%,v%,bo%
  15869. bo%=(bo$="OR")
  15870. F%=from%-1
  15871.   F%+=1:v%=
  15872. (F$(F%))
  15873.  op$ 
  15874.  "=":found%=(v%=t%)
  15875.  "<>":found%=(v%<>t%)
  15876.  "<":found%=(v%<t%)
  15877.  ">":found%=(v%>t%)
  15878.  "<=":found%=(v%<=t%)
  15879.  ">=":found%=(v%>=t%)
  15880.  (bo%=found%) 
  15881.  F%=to%
  15882. =found%
  15883. any(from%,to%,targ$,op$,bo$)
  15884.  F%,found%,f$,t$,bo%,case%
  15885. case%=
  15886. selected(queryW%,1)
  15887. bo%=(bo$="OR")
  15888. F%=from%-1
  15889.   F%+=1:f$=F$(F%)
  15890.  chartype%(F%) 
  15891. .    
  15892.  41,42,43,61,62:t$=
  15893. pos_neg(F%,targ$)
  15894. :t$=targ$
  15895.  case% 
  15896. u(f$)
  15897.  op$ 
  15898.  "{":
  15899.  chartype%(F%) 
  15900.       
  15901.  36,39:
  15902.       found%=
  15903. inmemo(F%,t$)
  15904.       
  15905. :found%=(
  15906. f$,t$)>0) 
  15907.         
  15908.  "}{":
  15909.  chartype%(F%) 
  15910.       
  15911.  36,39:
  15912. #      found%=(
  15913. inmemo(F%,t$))
  15914.       
  15915. :found%=(
  15916. f$,t$)=0)
  15917.         
  15918.  "=":found%=(f$=t$)
  15919.  "<>":found%=(f$<>t$)
  15920.  "<":found%=(f$<t$)
  15921.  ">":found%=(f$>t$)
  15922.  "<=":found%=(f$<=t$)
  15923.  ">=":found%=(f$>=t$)
  15924.  "$":found%=
  15925. wc(f$,t$)
  15926. !    
  15927. ":found%=
  15928. wc(f$,t$)
  15929.  (bo%=found%) 
  15930.  F%=to%
  15931. =found%
  15932. split
  15933.  X$,Q%,Q1%,Q2%,I%,t$
  15934. :X$=">=>=,<=<=,<>,}{,>=,<=,==,>>,<<,{{,=,<,>,{,~,":P%=0
  15935. %Q1%=
  15936. W$,""""):Q2%=
  15937. W$,"""",Q1%+1)
  15938. (X$)>0 
  15939.  P%=0
  15940. 8  Q%=
  15941. X$,","):op$=
  15942. X$,Q%-1):X$=
  15943. X$,Q%+1):P%=
  15944. W$,op$)
  15945.  Q1%>0 
  15946.  P%>Q1% 
  15947.  Q2%>P% 
  15948.  P%=0
  15949.  P%>0 
  15950.   field$=
  15951. W$,P%-1)
  15952.    target$=
  15953. W$,P%+
  15954. (op$))+","
  15955.   field$+=","
  15956.  op$="~" 
  15957.  op$="<>"
  15958.  op$ 
  15959.  "<>","}{":bo$="AND"
  15960. D    
  15961.  op$="<>" 
  15962. target$,$wc%)>0 
  15963. target$,$ws%)>0) 
  15964.  op$="
  15965.  "<=",">=":bo$="OR"
  15966. -    
  15967.  "<=<=",">=>=":op$=
  15968. op$,2):bo$="AND"
  15969. 3    
  15970.  "==","<<",">>","{{":op$=
  15971. op$,1):bo$="AND"
  15972. :bo$="OR"
  15973. C    
  15974.  op$="=" 
  15975. target$,$wc%)>0 
  15976. target$,$ws%)>0) 
  15977.  op$="$"
  15978.  moan_err%,
  15979. msg("Err40")
  15980. instring%=
  15981. "}{,{{,{",op$)>0
  15982. fnum(S$)
  15983. S$,1)="X" 
  15984.  concat%=
  15985. :=MaxFields%+3+
  15986. S$,1)="Y" 
  15987.  concat%=
  15988. :=MaxFields%+3+
  15989.  S$="KK" 
  15990.  concat%=
  15991. :=MaxFields%+1
  15992.  S$="SF" 
  15993.  concat%=
  15994. :=MaxFields%+2
  15995. ("&"+S$)
  15996. concat%=((N% 
  15997.  128)>0)
  15998. =(N% 
  15999.  127)
  16000. field(
  16001.  val%,f$,Z%)
  16002.  I%,F%,desc$,flag%
  16003. val%=
  16004. f$,1)="[" 
  16005. f$)="]" 
  16006. f$),2):val%=
  16007. f$))="#" 
  16008.  Scrcol$=
  16009. f$):f$=
  16010. f$)):flag%=
  16011.  I%<fields% 
  16012.  F%=0
  16013.   I%+=1
  16014. u(Tag$(I%))=
  16015. u(f$) 
  16016.  F%=I%
  16017.  F%>0 
  16018. $  desc$=$
  16019. text(mainW%,desc%(F%))
  16020.  desc$<>"" 
  16021.  TitFd$+=desc$ 
  16022.  TitFd$+=f$
  16023.  flag% 
  16024.  TitFd$+="(Column "+Scrcol$+")," 
  16025.  TitFd$+=","
  16026.  moan_err%,
  16027. msg("Err8,"+f$)
  16028.  chartype%(F%) 
  16029.  3,6,46,47,54,56,57,74,75,77,78,79:val%=
  16030.  64,65,66,67:
  16031.  flag% 
  16032.  Scrcol$="0"
  16033.    vals%=val%:
  16034.  val% 
  16035.  val%=
  16036. dfield(d$)
  16037.  I%,F%
  16038.  I%<fields% 
  16039.  F%=0
  16040.   I%+=1
  16041. text(mainW%,desc%(I%)))=
  16042. u(d$) 
  16043.  F%=I%
  16044. find_fields(S$,sep$,
  16045.  tabs$)
  16046.  f$,F$,C$,L$,P%,Q%,F%,length%,X%
  16047. %Q%=1:length%=0:tabs$="":TitFd$=""
  16048.   P%=
  16049. S$,sep$,Q%)
  16050.  P%>0 
  16051. S$,Q%,P%-Q%)
  16052.   F%=
  16053. field(X%,f$,
  16054.   length%+=len%(F%)+2
  16055. -  L$=
  16056. ~(len%(F%)+1):
  16057. (L$)=1 
  16058.  L$="0"+L$
  16059.   tabs$+=L$
  16060. %  F$=
  16061. ~(F%):
  16062. (F$)=1 
  16063.  F$="0"+F$
  16064.   C$+=F$
  16065.   Q%=P%+1
  16066. length%+=
  16067. (RA%))+1
  16068. ~(length%)
  16069. tabs$=L$+tabs$
  16070. strip_brackets
  16071. W$,1)="("
  16072.   left%+=1:W$=
  16073. W$,2)
  16074. W$)=")"
  16075.   right%+=1:W$=
  16076. add_brackets
  16077.  left%>0
  16078.   E$="("+E$:left%-=1
  16079.  right%>0
  16080.   E$+=")":right%-=1
  16081. build_title(T%)
  16082.  change%
  16083. #TitFd$=
  16084. TitFd$):TitTg$=
  16085. TitTg$)
  16086. TitFd$,"TIME$")=0 
  16087. TitFd$,",")>0 
  16088. TitFd$,"-")>0) 
  16089.  bo$ 
  16090. &    
  16091.  "OR":TitFd$="One of:"+TitFd$
  16092.  "AND":
  16093.  op$ 
  16094. ;      
  16095.  "<>":TitFd$="None of:"+TitFd$:op$="=":change%=
  16096. ;      
  16097.  "}{":TitFd$="None of:"+TitFd$:op$="{":change%=
  16098. #      
  16099. :TitFd$="All of:"+TitFd$
  16100.         
  16101.  T%>1 
  16102.  bo$ 
  16103. ."&    
  16104.  "OR":TitTg$="one of:"+TitTg$
  16105.  "AND":
  16106.  op$ 
  16107. .%1      
  16108.  "<>":TitTg$="none of:"+TitTg$:op$="="
  16109. .&1      
  16110.  "}{":TitTg$="none of:"+TitTg$:op$="{"
  16111. .''      
  16112. ":TitTg$="any of:"+TitTg$
  16113. .(I      
  16114.  change% 
  16115.  TitTg$="any of:"+TitTg$ 
  16116.  TitTg$="all of:"+TitTg$
  16117. .)        
  16118.  op$ 
  16119.  "{":op$=" contains "
  16120. ..%  
  16121.  "}{":op$=" does not contain "
  16122. ./,  
  16123.  "$":op$=" has wild-card match with "
  16124. .07  
  16125. ":op$=" does not have wild-card match with ":
  16126. Title$+=TitFd$+op$+TitTg$
  16127. expand(string$,table$,
  16128.  ExpLen%,
  16129.  subst$,
  16130.  scrcol%)
  16131.  p$,s$,start%,F%,I%,ind%,row%,field%,subst%,exact%,pos%,epos%,exp%,P%,T%,Rows%,TabFields%,Rec%,offset%,heading%,colours$
  16132. subst$=string$
  16133.  table$="" 
  16134.  ExpLen%=0:=string$:
  16135.  ### Not linked ###
  16136. table$,",")
  16137.  P%>0 
  16138.   exp%=
  16139. table$,P%+1))
  16140.   table$=
  16141. table$,P%-1)
  16142.  exp%=1
  16143. .?*field%=
  16144. trailing_number(table$,exact%)
  16145. .@*subst%=
  16146. leading_number(scrcol%,table$)
  16147.  ### field% is the linked field, subst% (if >=0) is the one to substitute on entry ###
  16148. table_number(table$)
  16149.  T%<0 
  16150.  ExpLen%=0:=string$:
  16151.  ### Table not found ###
  16152. p$=printrel$(T%)
  16153. .E`NewTab%=(
  16154. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)="
  16155.  exp%>TabFields% 
  16156.  exp%=1
  16157.  TabFields%=0 
  16158.  ExpLen%=0:=string$:
  16159.  ### Nothing to expand to! ###
  16160. .H*extra%=-NewTab%*(Rows%*(TabFields%+1))
  16161.  subst%>=0 
  16162.  pos%=
  16163. table_field(subst%,tabfieldlen%()) 
  16164.  pos%=
  16165. table_field(field%,tabfieldlen%())
  16166.  p$<>"" 
  16167.   ExpLen%=0
  16168.  I%=1 
  16169. (p$) 
  16170.     F%=
  16171. p$,I%,3))
  16172. .N#    ExpLen%+=tabfieldlen%(F%)+2
  16173.   ExpLen%-=2
  16174. .Q"  
  16175.  ExpLen%=tabfieldlen%(exp%)
  16176. .S6start%=SHtabptr%(T%)+offset%-Rec%:ind%=start%+pos%
  16177.   row%+=1:ind%+=Rec%
  16178.  row%>Rows% 
  16179.  $ind%=subst$
  16180.  row%>Rows% 
  16181.  subst$="":=string$:
  16182.  ## String not in table ###
  16183. .X;ind%=start%+row%*Rec%:
  16184.  subst%>=0 
  16185.  subst$=$(ind%+pos%)
  16186.  p$<>"" 
  16187.  I%=1 
  16188. (p$) 
  16189.     F%=
  16190. p$,I%,3))
  16191. .\,    pos%=
  16192. table_field(F%,tabfieldlen%())
  16193. .]4    s$+=
  16194. pad($(ind%+pos%),tabfieldlen%(F%))+"  "
  16195.   s$=
  16196. .a-  epos%=
  16197. table_field(exp%,tabfieldlen%())
  16198. .b5  ind%+=epos%:s$=$ind%:
  16199.  ### Return 2nd field ###
  16200. n(F%)
  16201.  T%,row%,ind%,start%,Rows%,Rec%,TabFields%,pos%,valpos%,N%,field%,subst%,table$,S$,exact%,scrcol%
  16202.  link$(F%)="" 
  16203. S$=$Rf%(F%)
  16204. table$=link$(F%)
  16205. .k*field%=
  16206. trailing_number(table$,exact%)
  16207. .l*subst%=
  16208. leading_number(scrcol%,table$)
  16209. .m/table%=
  16210. table_number(table$):
  16211.  table%<0 
  16212. .nYT$=
  16213. table_info(table%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  16214.  TabFields%=field% 
  16215. softerror("",54):=0
  16216.  subst%>0 
  16217. .q.  pos%=
  16218. table_field(subst%,tabfieldlen%())
  16219. .r0  
  16220.  pos%=
  16221. table_field(field%,tabfieldlen%())
  16222. .t1valpos%=
  16223. table_field(field%+1,tabfieldlen%())
  16224. .u)start%=SHtabptr%(table%)+offset%-Rec%
  16225.  row%+=1
  16226. .w   ind%=start%+row%*Rec%+pos%
  16227.  row%>Rows% 
  16228.  S$=$ind%
  16229.  row%<=Rows% 
  16230. .z#  ind%=start%+row%*Rec%+valpos%
  16231.   N%=
  16232. ($ind%)
  16233.  N%=0
  16234. pad(s$,L%)
  16235. L%," "),L%)
  16236. padL(s$,L%)
  16237. L%," ")+s$,L%)
  16238. stripright(s$,c$)
  16239. s$)=c$
  16240.   s$=
  16241. trim(wi%,ic%)
  16242. selected(prefsW%,42) 
  16243. text(wi%,ic%)=
  16244. stripright($
  16245. text(wi%,ic%)," ")
  16246. redraw_icon(wi%,ic%)
  16247. include_fields
  16248.  Hdlen%,Datlen%,hlm%,dlm%,I%,F%,f$,Head$,limit%,pad%,col%,fail%,n$,y$,S$,SF$,pos%,width%,pending%,first%,tail%,tail$,last%,N%,S%,V%,w%,memo%,scroll%,scrcol%
  16249. nosort%=
  16250. numfirst%=
  16251. margin_check
  16252. pos%=Lmargin%
  16253. numeric%()=
  16254. #maxlen%(MaxFields%+1)=KL%(key%)
  16255. first%=
  16256. :last%=
  16257. (Form$)-1
  16258.  I%=1 
  16259.  last% 
  16260. &  F%=
  16261. fnum(
  16262. Form$,I%,2)):scroll%=
  16263.   N%+=1
  16264.   Tab%(N%)=pos%
  16265. selected(printW%,46) 
  16266.     F$=$
  16267. text(printW%,44)
  16268. I    
  16269.  F$=Tag$(F%) 
  16270. (F$)=N% 
  16271.  sorton%=N%:Title1$+=
  16272. msg("Err201,"+F$)
  16273.   V%=chartype%(F%)
  16274.  F%=0 
  16275.  F%=MaxFields%+2 
  16276.  V%=3:
  16277.  Justify record & subfile numbers
  16278. selected(printW%,5) 
  16279. 7    f$=
  16280. expand("@#*",link$(F%),Datlen%,SF$,scrcol%)
  16281.  Datlen%=maxlen%(F%)
  16282. C    
  16283.  36,39:memo%=
  16284. set_format("vert"):maxlen%(F%)=0:Datlen%=0
  16285. 3    
  16286.  41,42,43,61,62:maxlen%(F%)=
  16287. no_yes(F%,F$)
  16288.  64,65,66,67:
  16289. =    S%=
  16290. scroller_number(F%):scroll%=
  16291. :scrcol%(S%)=scrcol%
  16292.  ScrollForm$ 
  16293. M      
  16294.  "R":maxlen%(F%)=
  16295. max_scroller_length(S%,F%,V%-63,scrcol%,Datlen%)
  16296. R      
  16297.  "C":maxlen%(F%)=
  16298. max_row_length(S%,F%,V%-63,scrcol%,Datlen%):nosort%=
  16299.         
  16300.     Datlen%=0
  16301.  Datlen%=0 
  16302.  Datlen%=maxlen%(F%) 
  16303.  maxlen%(F%)=Datlen%
  16304. selected_esg(printW%,1) 
  16305. 3    
  16306.  1:Head$=Tag$(F%):tail%=2:tail$=":"+
  16307. (160)
  16308. D    
  16309.  V%>250 
  16310.  Head$=Tag$(F%) 
  16311.  Head$=$
  16312. text(mainW%,(desc%(F%)))
  16313.      tail%=2:tail$=":"+
  16314. (160)
  16315. *    
  16316.  36:Head$="":tail%=1:tail$=
  16317. (160)
  16318.  F%=0 
  16319.  Head$="RECORD":Datlen%=6
  16320.  F%=MaxFields%+1 
  16321.  Head$="KEY":Datlen%=KL%(key%)
  16322.  F%=MaxFields%+2 
  16323.  Head$="SUBFILE":Datlen%=1
  16324.   Hdlen%=
  16325. (Head$)
  16326.  Hdlen%>hlm% 
  16327.  hlm%=Hdlen%
  16328.  Datlen%>dlm% 
  16329.  dlm%=Datlen%
  16330.  concat% 
  16331.  first%:
  16332. 5    width%=Datlen%+
  16333. (spacer$):pending%=
  16334. :first%=
  16335. +    
  16336.  reportdest$="Printer" 
  16337.  width%+=2
  16338.  concat% 
  16339.  (I%<last%):
  16340. :    width%+=Hdlen%+tail%+Datlen%+
  16341. (spacer$):pending%=
  16342. +    
  16343.  reportdest$="Printer" 
  16344.  width%+=2
  16345.  pending%:
  16346. $    width%+=Hdlen%+tail%+Datlen%
  16347. #    
  16348.  width%>dlm% 
  16349.  dlm%=width%
  16350.     pending%=
  16351. :first%=
  16352. %    
  16353.  Hdlen%>hlm% 
  16354.  hlm%=Hdlen%
  16355.  format$ 
  16356.  "horiz","table":
  16357. !    PrintFields%=
  16358. (Form$) 
  16359. -    pad%=Datlen%-Hdlen%:
  16360.  pad%<0 
  16361.  pad%=0
  16362. +    
  16363.  I%<last% 
  16364.  Ls%=
  16365. (spacer$) 
  16366.  Ls%=0
  16367. B    SHheadptr%=
  16368. claim_page(headanchor%,pos%+pad%+Hdlen%+Ls%+4)
  16369. 2      
  16370.  3,6,46,47,54,56,57,74,75,77,78,79,254:
  16371.       numeric%(N%)=
  16372. I      $(SHheadptr%+pos%+pad%)=Head$:?(SHheadptr%+pos%+pad%+Hdlen%)=32
  16373. A      
  16374. :$(SHheadptr%+pos%)=Head$:?(SHheadptr%+pos%+Hdlen%)=32
  16375.         
  16376. !    
  16377.  reportdest$="Printer" 
  16378. N      maxlenP%(N%)=
  16379. how_wide("",SHheadptr%+pos%,Hdlen%+Ls%,headerfont%,-1)
  16380.         
  16381.     pos%+=pad%+Hdlen%+Ls%
  16382.  "vert":
  16383.     PrintFields%=2
  16384. !    
  16385.  reportdest$="Printer" 
  16386. 6      w%=
  16387. how_wide(Head$+tail$,0,0,headerfont%,-1)
  16388. +      
  16389.  w%>maxlenP%(1) 
  16390.  maxlenP%(1)=w%
  16391. M    
  16392.  100,254,255:
  16393.  key,record number,or calculation included. Do nothing
  16394. 1    
  16395.  vtype$(V%)="L" 
  16396.  scrolldata%(S%,9)=N%
  16397.   truelen%(F%)=Hdlen%
  16398.  truelen%(F%)>maxlen%(F%) 
  16399.  maxlen%(F%)=truelen%(F%)
  16400. Tab%(N%+1)=pos%
  16401.  format$ 
  16402.  "horiz","table":LenLine%=pos%+2
  16403.  "vert":Tab%(1)=Lmargin%:Tab%(2)=hlm%+tail%+Tab%(1):Tab%(3)=0
  16404.  memo% 
  16405. )    
  16406.  TextLine%>dlm% 
  16407.  dlm%=TextLine%
  16408. M    
  16409.  TextLine%=0 
  16410.  TextLine%=dlm%:
  16411.  TextLine% will be 0 if 'A' specified
  16412. :    
  16413.  TextLine%>254 
  16414. softerror("",223):TextLine%=254
  16415.   LenLine%=Tab%(2)+dlm%+2
  16416.  "label":LenLine%=0
  16417. no_yes(F%,
  16418.  P%,Q%,V$,L%,no$,yes$,what$
  16419. val(mainW%,field%(F%))
  16420. V$,"Q")
  16421.  P%>0 
  16422. +  Q%=
  16423. V$,";S"):V$=
  16424. V$,P%+1,Q%-P%-1)+","
  16425. ,  P%=
  16426. V$,","):no$=
  16427. V$,P%-1):V$=
  16428. V$,P%+1)
  16429. -  P%=
  16430. V$,","):yes$=
  16431. V$,P%-1):V$=
  16432. V$,P%+1)
  16433.   P%=
  16434. V$,",")
  16435.  P%>0 
  16436.  what$=
  16437. V$,P%-1)
  16438.  no$="N":yes$="Y":what$="" 
  16439.  " ":F$=yes$
  16440. (0):F$=no$
  16441.  chartype%(F%) 
  16442.  41,42,43:F$=no$
  16443.  61,62:F$=what$
  16444. (no$)
  16445. (yes$)>L% 
  16446. (yes$)
  16447. set_format(S$)
  16448. deselect(printW%,
  16449. selected_esg(printW%,3))
  16450. deselect(printerW%,
  16451. selected_esg(printerW%,2))
  16452.  "horiz":
  16453. select(printW%,15)
  16454.  "vert":
  16455. select(printW%,16)
  16456.  "table":
  16457. select(printerW%,7)
  16458.  "label":
  16459. select(printerW%,8)
  16460. format$=S$
  16461. save_selection
  16462.  P%,T%,I%,F%,J%
  16463. /"-P%=savebuff%:$P%=printorder$:P%+=
  16464. ($P%)+1
  16465.  T%=0 
  16466.  LastTable%
  16467. /$# $P%=printrel$(T%):P%+=
  16468. ($P%)+1
  16469. $P%="***":P%+=
  16470. ($P%)+1
  16471.  I%=1 
  16472. (printorder$)-1 
  16473. /("  F%=
  16474. fnum(
  16475. printorder$,I%,2))
  16476.  chartype%(F%) 
  16477. /*,    
  16478.  3,6,46,47,54,56,57,74,75,77,78,79:
  16479.  J%=0 
  16480. /,N      
  16481. selected(numscrollW%,(calcrow%?F%)*8-6+J%) 
  16482.  $P%="ON" 
  16483.  $P%="OFF"
  16484.       P%+=
  16485. ($P%)+1
  16486.  Ecalc%>0 
  16487.  I%=0 
  16488.  Ecalc%-1
  16489.  J%=0 
  16490. /4+      $P%=ephemera$(I%,J%):P%+=
  16491. ($P%)+1
  16492. /88Start%=savebuff%:End%=Start%+P%-savebuff%:Type%=&7F3
  16493. load_selection(f$)
  16494.  F%,I%,J%,T%,F,new%,p$
  16495. clear_selection
  16496. printorder$=
  16497. printorder$,3)="!!!" 
  16498.  !Pcol%=
  16499. printorder$,4)):printorder$=
  16500. T%=-1:printrel$()=""
  16501.  p$<>"***"
  16502.   T%+=1
  16503.   p$=
  16504.  p$<>"" 
  16505.  p$<>"***" 
  16506. select(printW%,5)
  16507.     printrel$(T%)=p$
  16508.  tableW%(T%)>0 
  16509. /If      NewTab%=(
  16510. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)="
  16511. /J0      extra%=-NewTab%*(Rows%*(TabFields%+1))
  16512.       
  16513.  I%=1 
  16514. (p$) 
  16515. /L$        tablefield%=
  16516. p$,I%,3))
  16517. /M3        
  16518. select(tableW%(T%),tablefield%+extra%)
  16519.       
  16520. /O        
  16521. select_them(
  16522. Ecalc%=0
  16523.   F%=MaxFields%+3+Ecalc%
  16524.  J%=0 
  16525.     S$=
  16526.     ephemera$(Ecalc%,J%)=S$
  16527.  J%=2 
  16528.  Tag$(F%)=S$
  16529. /Z1    
  16530.  J%=3 
  16531.  len%(F%)=
  16532. (S$):maxlen%(F%)=
  16533. /[$    
  16534.  J%=4 
  16535.  chartype%(F%)=
  16536.   Ecalc%+=1
  16537. close_file(F)
  16538. lit(printM%,7,
  16539. lit(printM%,8,
  16540. lit(printM%,9,
  16541. lit(mainM%,7,
  16542. selected(passW%,13))
  16543. select_them(calc%)
  16544.  F%,I%,J%,S%,col%
  16545.  I%=1 
  16546. (printorder$)-1 
  16547. /i"  F%=
  16548. fnum(
  16549. printorder$,I%,2))
  16550. select(matchW%,4)
  16551. /l)    
  16552.  MaxFields%+1:
  16553. select(matchW%,6)
  16554. /m*    
  16555.  MaxFields%+2:
  16556. select(matchW%,12)
  16557.  chartype%(F%) 
  16558.       
  16559.  36,60:
  16560. /q0      col%=
  16561. get_icon_cols(mainW%,field%(F%))
  16562. /r2      col%=((col%>>4) 
  16563.  (col%<<4)) 
  16564.  %11111111
  16565. /s7      
  16566. set_icon_cols(mainW%,field%(F%),col%)       
  16567.       
  16568.  41,42,43,61,62:
  16569. /u0      col%=
  16570. get_icon_cols(mainW%,field%(F%))
  16571. /v2      col%=((col%>>4) 
  16572.  (col%<<4)) 
  16573.  %11111111
  16574. /w0      
  16575. set_icon_cols(mainW%,field%(F%),col%)
  16576. /x.      
  16577.  3,6,46,47,54,56,57,74,75,77,78,79:
  16578. /y$      
  16579. select(mainW%,field%(F%))
  16580. /z$      
  16581. enable_row(calcrow%?F%,
  16582.       
  16583.  calc% 
  16584.         
  16585.  J%=0 
  16586. /}N          
  16587. set_icon(numscrollW%,(calcrow%?F%)*8-6+J%,(
  16588. #F="ON"))
  16589.         
  16590.       
  16591.       
  16592.  64,65,66,67:
  16593. $      
  16594. select(mainW%,field%(F%))
  16595. !      S%=
  16596. scroller_number(F%)
  16597. &      
  16598.  J%=0 
  16599.  scrolldata%(S%,6)-1
  16600. &        
  16601. invert(scrollerW%(S%),J%)
  16602.       
  16603. 9      
  16604.  F%<=MaxFields% 
  16605. select(mainW%,field%(F%))
  16606.         
  16607. select_range(first%,last%,show%)
  16608.  F%,T%,F$,wi%,ic%,icon%,handle%
  16609.  first%>last% 
  16610.  first%,last%
  16611.  first%=1 
  16612.  last%=fields% 
  16613.  printorder$="" 
  16614.  printorder$=
  16615. printorder$))
  16616. wi%=mainW%
  16617.  F%=first% 
  16618.  last%
  16619.   ic%=field%(F%)
  16620.  chartype%(F%) 
  16621.  41,42,43,61,62:
  16622. $    col%=
  16623. get_icon_cols(wi%,ic%)
  16624. F    
  16625.  (col% 
  16626.  %1111)>=2 
  16627.  col%=((col%>>4) 
  16628.  (col%<<4)) 
  16629.  %11111111
  16630. .    
  16631.  show% 
  16632. set_icon_cols(wi%,ic%,col%)
  16633. '    F$=
  16634. ~(F%):
  16635. (F$)=1 
  16636.  F$="0"+F$
  16637.     printorder$+=F$
  16638. K    
  16639.  0,1,2,4,5,7,8,39,48,49,50,51,52,53,55,58,63,68,69,70,71,72,73,76:
  16640. =    
  16641.  len%(F%)>0 
  16642. get_icon_cols(wi%,ic%)<>winback%*17 
  16643. )      F$=
  16644. ~(F%):
  16645. (F$)=1 
  16646.  F$="0"+F$
  16647.       printorder$+=F$
  16648. $      
  16649.  show% 
  16650. select(wi%,ic%)
  16651.         
  16652. ,    
  16653.  3,6,46,47,54,56,57,74,75,77,78,79:
  16654. =    
  16655.  len%(F%)>0 
  16656. get_icon_cols(wi%,ic%)<>winback%*17 
  16657. )      F$=
  16658. ~(F%):
  16659. (F$)=1 
  16660.  F$="0"+F$
  16661.       printorder$+=F$
  16662. $      
  16663.  show% 
  16664. select(wi%,ic%)
  16665. $      
  16666. enable_row(calcrow%?F%,
  16667.         
  16668.  36,60:
  16669. '    F$=
  16670. ~(F%):
  16671. (F$)=1 
  16672.  F$="0"+F$
  16673.     printorder$+=F$
  16674. $    col%=
  16675. get_icon_cols(wi%,ic%)
  16676. 0    col%=((col%>>4) 
  16677.  (col%<<4)) 
  16678.  %11111111
  16679. .    
  16680.  show% 
  16681. set_icon_cols(wi%,ic%,col%)
  16682.  64,65,66,67:
  16683. select(wi%,ic%)
  16684.     S%=
  16685. scroller_number(F%)
  16686.     handle%=scrollerW%(S%)
  16687. '    
  16688.  icon%=0 
  16689.  scrolldata%(S%,6)-1
  16690.        
  16691. select(handle%,icon%)
  16692.  icon%
  16693. '    F$=
  16694. ~(F%):
  16695. (F$)=1 
  16696.  F$="0"+F$
  16697.     printorder$+=F$
  16698. lit(printM%,7,
  16699. lit(printM%,8,
  16700. lit(mainM%,7,
  16701. selected(passW%,13))
  16702. shade(matchW%,7,printorder$<>"")
  16703. lit(printM%,9,printorder$<>"")
  16704. clear_selection
  16705.  F%,T%,new%,wi%,ic%
  16706.  F%=1 
  16707.  fields%
  16708.  chartype%(F%) 
  16709. (    
  16710.  Filter button: do nothing
  16711.  36,41,42,43,60,61,62:
  16712. .    col%=
  16713. get_icon_cols(mainW%,field%(F%))
  16714. E    
  16715.  (col% 
  16716.  %1111)<2 
  16717.  col%=((col%>>4) 
  16718.  (col%<<4)) 
  16719.  %11111111
  16720. .    
  16721. set_icon_cols(mainW%,field%(F%),col%)
  16722. ,    
  16723.  3,6,46,47,54,56,57,74,75,77,78,79:
  16724. ?    
  16725. enable_row(calcrow%?F%,
  16726. deselect(mainW%,field%(F%))
  16727.  64,65,66,67:
  16728. $    
  16729. deselect(mainW%,field%(F%))
  16730.     S%=
  16731. scroller_number(F%)
  16732.     wi%=scrollerW%(S%)
  16733. %    
  16734.  ic%=0 
  16735.  scrolldata%(S%,6)-1
  16736.       
  16737. deselect(wi%,ic%)
  16738. &    
  16739. deselect(mainW%,field%(F%))
  16740. printorder$=""
  16741.     T%=-1
  16742.  T%<LastTable%
  16743.   T%+=1
  16744. b  NewTab%=(
  16745. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)="
  16746. ,  extra%=-NewTab%*(Rows%*(TabFields%+1))
  16747.   p$=printrel$(T%)
  16748.  p$<>"" 
  16749.  tableW%(T%)>0 
  16750.       
  16751.  I%=1 
  16752. (p$) 
  16753. $        tablefield%=
  16754. p$,I%,3))
  16755. 5        
  16756. deselect(tableW%(T%),tablefield%+extra%)
  16757.       
  16758.         
  16759. printrel$()=""
  16760. ephemera$()="":Ecalc%=0
  16761. lit(printM%,7,
  16762. lit(printM%,8,
  16763. lit(printM%,9,
  16764. lit(mainM%,7,
  16765. shade(matchW%,7,
  16766. deselect(matchW%,4):
  16767. deselect(matchW%,6):
  16768. deselect(matchW%,12)
  16769. load_query(f$,wi%,ic%)
  16770.  wi% 
  16771.  mainW%:
  16772.  ic% 
  16773. F    
  16774.  field%(buttonfield%(0,22)):
  16775. select(wi%,ic%):
  16776. filter(wi%,4,
  16777. .    
  16778. selected(passW%,14) 
  16779. match(0,0)
  16780.  keypadW%:
  16781. select(wi%,22):
  16782. filter(wi%,4,
  16783. 7    
  16784.  File double-click; not dropped on window
  16785. 6  !block%=queryW%:
  16786.  "Wimp_GetWindowState",,block%
  16787.  ((block%!32) 
  16788.  (1<<16))=0 
  16789. match(0,0)
  16790.  "OS_File",255,f$,Query%
  16791. query$=$Query%
  16792. set_caret(0,queryW%,0)
  16793. redraw_icon(queryW%,0)
  16794. design_field(b%,ic%,menu%)
  16795.  w%,h%,bg%,wht%,F%
  16796. close_window(createW%)
  16797.  fields%>0 
  16798. $  fieldsM%=
  16799. field_menu(items%,0)
  16800. 9  ptr%=designM%+52:ptr%!4=fieldsM%:
  16801. lit(designM%,1,
  16802. lit(designM%,1,
  16803.  $Reformatted%<>"" 
  16804. lit(designM%,7,
  16805. lit(designM%,2,
  16806. lit(designM%,3,
  16807. lit(designM%,4,
  16808. lit(designM%,5,
  16809.  adjust%:
  16810.   live%()=19,20,-1
  16811.   F%=
  16812. get_field(ic%)
  16813.  chartype%(F%) 
  16814. 2    
  16815.  64,65,66,67:
  16816. enable(createW%,
  16817. ):wht%=730
  16818. &    
  16819. enable(createW%,
  16820. ):wht%=640
  16821. P  live%()=11,18,21,22,23,24,35,47,6,26,30,39,40,48,54,-1:
  16822. enable(createW%,
  16823. '  live%()=29,-1:
  16824. enable(createW%,
  16825. B  live%()=30,-1:
  16826. enable(createW%,(len%(F%)=0 
  16827.  dbtype$="new"))
  16828. A  live%()=55,-1:
  16829. enable(createW%,(vtype$(chartype%(F%))="E"))
  16830. set_icon(createW%,55,(mandatory%?F%=1))
  16831. set_icon(createW%,63,(displayit%?F%=1)) 
  16832.  dbtype$="new" 
  16833. 8    live%()=22,23,48,54,21,35,-1:
  16834. enable(createW%,
  16835. -    live%()=18,-1:
  16836. enable(createW%,ic%<0)
  16837. 0 .    live%()=29,-1:
  16838. enable(createW%,ic%>=0)
  16839.  ic%>=0:
  16840. 0#*  live%()=11,18,-1:
  16841. enable(createW%,
  16842. 0$M  live%()=21,22,23,24,35,47,48,6,26,29,30,39,40,54,-1:
  16843. enable(createW%,
  16844. 0&0  live%()=29,30,39,40,-1:
  16845. enable(createW%,
  16846. 0'G  live%()=21,22,23,24,35,47,48,6,26,11,18,54,-1:
  16847. enable(createW%,
  16848. 0)!posx%=x%:posy%=y%:dragbutt%=0
  16849. 0*3!block%=mainW%:
  16850.  "Wimp_GetWindowState",,block%
  16851. x%+=block%!20-block%!4
  16852. y%+=block%!24-block%!16
  16853. 0-5!block%=createW%:
  16854.  "Wimp_GetWindowState",,block%
  16855. 0.%closed%=((block%!32 
  16856.  (1<<16))=0)
  16857.  %1111111 
  16858. 00.  
  16859.  1,1024:
  16860.  fields%=0 
  16861. softerror("",62)
  16862.  ic%>=0 
  16863. 03(    fieldfunc$="create":$InsText%=""
  16864. 045    
  16865. deselect(createW%,
  16866. selected_esg(createW%,1))
  16867. set_up_edit
  16868. close_window(createW%)
  16869. 071    
  16870. position_window(createW%,0,0,0,wht%,0,0)
  16871. 08     
  16872. set_caret(0,createW%,4)
  16873. 09      
  16874.  closed% 
  16875. 0<C    
  16876.  (ic% 
  16877.  2)=1 
  16878.  drag%=6:dragbutt%=16 
  16879.  drag%=5:dragbutt%=64
  16880. 0=$    
  16881. init_drag(mainW%,ic%,drag%)
  16882. 0@%  
  16883. shade(createW%,44,(fields%>0))
  16884. 0A&  fieldfunc$="create":$InsText%=""
  16885. 0B3  
  16886. deselect(createW%,
  16887. selected_esg(createW%,1))
  16888. 0C#  
  16889. shade(createW%,49,snapgrid%)
  16890. 0D-  
  16891.  ic%<0 
  16892. set_up_create 
  16893. set_up_edit
  16894. close_window(createW%)
  16895.  menu% 
  16896. 0G+    
  16897. show_menu(designM%,posx%-64,posy%)
  16898. 0HL    
  16899. position_window(createW%,0,0,0,wht%,0,0):
  16900. set_caret(0,createW%,4)
  16901. 0J<  
  16902.  closed% 
  16903. init_drag(mainW%,ic%,5):dragbutt%=64
  16904. enable(wi%,on%)
  16905. shade(wi%,live%(I%),on%)
  16906.   I%+=1
  16907.  live%(I%)=-1
  16908. set_up_edit
  16909.  adjust% 
  16910.  live%()=21,54,24,22,47,35,23,48,-1:
  16911. enable(createW%,
  16912. lit(designM%,0,
  16913. 0Y.Fieldnumber%=
  16914. get_field(ic%):oldfield%=ic%
  16915. 0Z!type%=chartype%(Fieldnumber%)
  16916.  (ic% 
  16917.  2)=0 
  16918.  Tag$(Fieldnumber%)<>"" 
  16919.  ic%+=1
  16920. 0\>!block%=mainW%:block%!4=ic%:
  16921.  "Wimp_GetIconState",,block%
  16922. 0]Ix%=block%!8:y%=block%!12:w%=block%!16-block%!8:h%=block%!20-block%!12
  16923.  (oldfield% 
  16924.  2)=0 
  16925.  Tag$(Fieldnumber%)="" 
  16926.  x%+=w%:w%=0:h%=0
  16927. 0_7$boxX%=
  16928. (x%):$boxY%=
  16929. (y%):$boxW%=
  16930. (w%):$boxH%=
  16931. 0`'wht%=640:
  16932. set_scroll_def(0,0,
  16933.  vtype$(type%) 
  16934. 0bE  
  16935.  "E":
  16936. shade(createW%,21,
  16937. select(createW%,21):
  16938. set_limits(0)
  16939. 0cE  
  16940.  "C":
  16941. shade(createW%,47,
  16942. select(createW%,47):
  16943. set_limits(1)
  16944. 0dE  
  16945.  "T":
  16946. shade(createW%,24,
  16947. select(createW%,24):
  16948. set_limits(2)
  16949. 0eE  
  16950.  "X":
  16951. shade(createW%,22,
  16952. select(createW%,22):
  16953. set_limits(3)
  16954. 0fE  
  16955.  "K":
  16956. shade(createW%,23,
  16957. select(createW%,23):
  16958. set_limits(4)
  16959. 0gE  
  16960.  "O":
  16961. shade(createW%,48,
  16962. select(createW%,48):
  16963. set_limits(5)
  16964. 0hE  
  16965.  "S":
  16966. shade(createW%,35,
  16967. select(createW%,35):
  16968. set_limits(6)
  16969. 0iR  
  16970.  "L":wht%=730:
  16971. set_scroll_def(Fieldnumber%,type%-63,adjust% 
  16972.  (ic%>0),
  16973. 0j?  
  16974. shade(createW%,54,
  16975. select(createW%,54):
  16976. set_limits(7)
  16977.  I%=0 
  16978. lit(ftypeM%(6),I%,
  16979. 0n$  
  16980.  I%<8 
  16981. lit(ftypeM%(0),I%,
  16982. 0o$  
  16983.  I%=5 
  16984. lit(ftypeM%(3),I%,
  16985. 0q$fieldtype%=type%:currenttype%=-1
  16986.   currenttype%+=1
  16987.  ?(flist%(menunumber%)+currenttype%+1)=fieldtype% 
  16988.  currenttype%>lasttype%
  16989.  currenttype%>lasttype% 
  16990. softerror(
  16991. (fieldtype%),221):
  16992. tick_one(ftypeM%(menunumber%),0,lasttype%-1,currenttype%)
  16993. 0w0$FtitleText%="Modify field "+
  16994. (Fieldnumber%)
  16995. 0x1$DescText%=$
  16996. text(mainW%,desc%(Fieldnumber%))
  16997. 0y $TagText%=Tag$(Fieldnumber%)
  16998. 0z#$LenText%=
  16999. (len%(Fieldnumber%))
  17000. 0{ $ValText%=vname$(fieldtype%)
  17001. deselect(createW%,
  17002. selected_esg(createW%,2))
  17003.  fix%(Fieldnumber%) 
  17004. 0~+  
  17005. select(createW%,45):$Fixpt%="0"
  17006. select(createW%,46):$Fixpt%="0"
  17007. select(createW%,14):$Fixpt%=
  17008. (fix%(Fieldnumber%))
  17009. &num%=(fieldtype%=3 
  17010.  fieldtype%=6)
  17011. shade(createW%,13,(
  17012. selected(createW%,14)))
  17013. shade(createW%,14,num%)
  17014. shade(createW%,45,num%)
  17015. shade(createW%,46,num%)
  17016. shade(createW%,6,
  17017. shade(createW%,63,
  17018.  fieldtype% 
  17019.  0,1,2,3,4,5,6,7,8,46,47,63:
  17020. shade(createW%,6,
  17021.  adjust%)
  17022.  36,37,38,60:
  17023. shade(createW%,63,
  17024. shade(createW%,15,(fieldtype%=3 
  17025.  fieldtype%=47))
  17026. shade(createW%,25,(fieldtype%=3))
  17027. &C$=calc$(Fieldnumber%):P%=
  17028. C$,"|")
  17029.  P%>0 
  17030. -  $mintext%=
  17031. C$,P%-1):$maxtext%=
  17032. C$,P%+1)
  17033.  $mintext%="":$maxtext%=""
  17034. $DesAction%="Edit field..."
  17035. set_up_create
  17036. select(createW%,21):
  17037. set_limits(0)
  17038. lit(designM%,0,
  17039.  adjust%)
  17040.  adjust% 
  17041.  dbtype$="new" 
  17042. lit(designM%,0,
  17043. lit(ftypeM%(3),5,
  17044.  I%=0 
  17045. lit(ftypeM%(6),I%,
  17046. -    
  17047.  I%<8 
  17048.  I%>0 
  17049. lit(ftypeM%(0),I%,
  17050. lit(ftypeM%(3),5,
  17051.  I%=0 
  17052. lit(ftypeM%(6),I%,
  17053. -    
  17054.  I%<8 
  17055.  I%>0 
  17056. lit(ftypeM%(0),I%,
  17057. 3$boxX%=
  17058. (x%):$boxY%=
  17059. (y%):$boxW%="0":$boxH%="0"
  17060. *$FtitleText%="New field "+
  17061. (fields%+1)
  17062. +$DescText%="":$TagText%="":$LenText%=""
  17063. )$Fixpt%="2":$mintext%="":$maxtext%=""
  17064. deselect(createW%,
  17065. selected_esg(createW%,2))
  17066. select(createW%,46)
  17067. !$DesAction%="Create field..."
  17068. empty_list
  17069.  L%,S$
  17070. %S$="No matching records":L%=
  17071. store_rec_num(-2)
  17072. store_string(S$,Lmargin%,
  17073.  L%>maxhead% 
  17074.  maxhead%=L%
  17075. #vrules%=
  17076. :spacer$=" ":nosort%=
  17077. remove_field(Field%,con%)
  17078.  F%,scrap%
  17079.  con% 
  17080. confirm(
  17081. msg("Err53"))=
  17082. )!block%=mainW%:block%!4=desc%(Field%)
  17083.  "Wimp_GetIconState",,block%
  17084. "posx%=block%!8:posy%=block%!12
  17085.  "Wimp_DeleteIcon",,block%
  17086. block%!4=field%(Field%)
  17087.  "Wimp_DeleteIcon",,block%
  17088.  Create two spurious fields to prevent nudge & adjust changing icon number!
  17089. ;scrap%=
  17090. create_icon(0,mainW%,0,0,0,0,&701A731,"",0,0,0)
  17091. ;scrap%=
  17092. create_icon(0,mainW%,0,0,0,0,&701A731,"",0,0,0)
  17093. fields%-=1
  17094. Calc$=calc$(Field%)
  17095.  F%=Field% 
  17096.  fields%
  17097.   desc%(F%)=desc%(F%+1):field%(F%)=field%(F%+1):Tag$(F%)=Tag$(F%+1):len%(F%)=len%(F%+1):chartype%(F%)=chartype%(F%+1):fix%(F%)=fix%(F%+1):calc$(F%)=calc$(F%+1)
  17098. calc$(fields%+1)=""
  17099. !block%=mainW%
  17100.  "Wimp_GetWindowState",,block%
  17101. ;posx%-=block%!20-block%!4:posy%-=block%!24-block%!16-48
  17102.  "Wimp_ForceRedraw",-1,block%!4,block%!8,block%!12,block%!16
  17103. create_field(Before%,x%,y%,update%,
  17104.  ok%)
  17105.  Desc%,tag$,Len%,Char%,F%,L%,LF%,OL%,x%,y%,width%,height%,dflg%,menflag%,F,chars%,N%,menufield%
  17106. wimp_error(
  17107.  fields%=MaxFields% 
  17108.  moan_err%,
  17109. msg("Err23,"+
  17110. (MaxFields%))
  17111.  $DescText%="" 
  17112.  $TagText%="" 
  17113.  fieldtype%<=8 
  17114.  moan_err%,
  17115. msg("Err149")
  17116. ($DescText%):LF%=
  17117. ($LenText%)
  17118.  L%=0 
  17119.  dflg%=(winback%<<28)+&701A711 
  17120.  dflg%=(winback%<<28)+&701A731
  17121.  fieldtype%<>60 
  17122.  LF%>246 
  17123.  moan_err%,
  17124. msg("Err64")
  17125. ($boxX%):y%=
  17126. ($boxY%):int%=
  17127. ($Gridsnap%):
  17128. snap(x%,y%,int%)
  17129. &width%=
  17130. ($boxW%):height%=
  17131. ($boxH%)
  17132.  fieldtype% 
  17133.  39,40,59:
  17134.   LF%=0
  17135.  width%=0 
  17136.  width%=100
  17137.  height%=0 
  17138.  height%=100
  17139.  35,44,64,65,66,67:LF%=0
  17140.  4,41,42,43,61,62,74,79:LF%=1
  17141.  8,48,50,68,70:LF%=8
  17142.  49,69:LF%=15
  17143.  51,71:LF%=10
  17144.  52,58,72:LF%=24
  17145.  53,55,73,76:LF%=3
  17146.  54,56,75,77:LF%=2
  17147.  57,78:LF%=4
  17148.  60:LF%=RLmax%
  17149.  adjust% 
  17150.   OL%=len%(update%)
  17151.  LF%>OL%:
  17152. ?    
  17153.  moan_err%,
  17154. msg("Err174,"+
  17155. (LF%)+","+
  17156. (len%(update%)))
  17157.  LF%<OL%:LF%=OL%
  17158.  vtype$(fieldtype%) 
  17159.  "K":
  17160.  Keypad button fields: do nothing here
  17161.  fieldtype% 
  17162. E    
  17163.  32,33,34,45,59:
  17164.  Print, Menu, Exit, Quit & Logo. Do nothing
  17165. >    
  17166.  LF%>0 
  17167.  $TagText%="" 
  17168.  moan_err%,
  17169. msg("Err16")
  17170. 8    
  17171.  Allow Unrestricted fields to be used as labels
  17172. 4    
  17173.  $TagText%="" 
  17174.  moan_err%,
  17175. msg("Err16")
  17176.  F%+=1
  17177.  $TagText%=Tag$(F%) 
  17178.  F%>fields%
  17179.  F%=update%:
  17180.  Do nothing
  17181.  fieldtype%=33 
  17182.  $TagText%=Tag$(F%) 
  17183.  $TagText%<>"":menufield%=F%
  17184.  F%<=fields% 
  17185.  $TagText%<>"":
  17186.  moan_err%,
  17187. msg("Err20")
  17188.  update%>0 
  17189. remove_field(update%,
  17190.  fieldtype%=33 
  17191.  menflag%=
  17192. 8fields%+=1:Tag$(fields%)=$TagText%:len%(fields%)=LF%
  17193.  fieldtype% 
  17194.  64,65,66,67:
  17195.   cols%=fieldtype%-63
  17196. )  height%=
  17197. text(createW%,56))*44+6
  17198. .  f$=$database%+"."+Tag$(fields%)+"scroll"
  17199.  "OS_File",8,f$
  17200. (f$+".Format")
  17201.  I%=1 
  17202.  cols%
  17203. $    N%=
  17204. text(createW%,I%+56))
  17205.     chars%+=N%+1
  17206. close_file(F)
  17207.  "OS_File",18,f$+".Format",&fff
  17208. 3  width%=
  17209. guess_width(chars%,fieldtype%,width%)
  17210.  width%=0 
  17211.  $TagText%<>"" 
  17212. c    
  17213.  len%(fields%)<70 
  17214.  width%=
  17215. guess_width(len%(fields%),fieldtype%,width%) 
  17216.  width%=70*16+16
  17217.  height%=0 
  17218.  width%>0 
  17219.  height%=48
  17220. !chartype%(fields%)=fieldtype%
  17221.  fieldtype% 
  17222. 1 *  
  17223.  3,6,46,47,54,56,57,74,75,77,78,79:
  17224. 1"1    
  17225. selected(createW%,45):fix%(fields%)=-1
  17226. 1#9    
  17227. selected(createW%,14):fix%(fields%)=
  17228. ($Fixpt%)
  17229. :fix%(fields%)=0
  17230. :fix%(fields%)=0
  17231. 1(%dwidth%=
  17232. string_width($DescText%)
  17233. 1)=SHformptr%=
  17234. claim_page(formanchor%,Fptr%-SHformptr%+L%+1)
  17235. 1*\desc%(fields%)=
  17236. create_icon(0,mainW%,x%-dwidth%,y%+2,dwidth%,44,dflg%,"",Fptr%,hand%,L%)
  17237. 1+!$Fptr%=$DescText%:Fptr%+=L%+1
  17238. $Fptr%=""
  17239.  fieldtype% 
  17240.   min$=$mintext%
  17241.   max$=$maxtext%
  17242. 11N  
  17243.  min$<>"" 
  17244.  max$<>"" 
  17245.  calc$(fields%)=min$+"|"+max$ 
  17246.  calc$(fields%)=""
  17247.   calc$(0)="LOADED"
  17248. 14)  min$=$mintext%:
  17249.  min$="" 
  17250.  min$="0"
  17251. 15*  max$=$maxtext%:
  17252.  max$="" 
  17253.  max$=min$
  17254. 16"  calc$(fields%)=min$+"|"+max$
  17255.   calc$(0)="LOADED"  
  17256.  fieldtype% 
  17257.  0,1,2,3,4,5,6,7,8,39,46,47,48,49,50,51,52,53,54,55,56,57,58,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79:valptr%=hand%
  17258. 1<+  
  17259.  40:$Fptr%="file_ff9":valptr%=1:L%=8
  17260. 1=2  
  17261.  59:valptr%=SHlogoptr%:$Fptr%=Tag$(fields%)
  17262. 1>#  
  17263. :valptr%=hvalid%(fieldtype%)
  17264. 1@=SHformptr%=
  17265. claim_page(formanchor%,Fptr%-SHformptr%+L%+1)
  17266. 1AVfield%(fields%)=
  17267. icon_design(fields%,fieldtype%,x%,y%,width%,height%,valptr%,L%,
  17268. redraw_icon(mainW%,desc%(fields%)):
  17269. redraw_icon(mainW%,field%(fields%))
  17270.  Before%<fields% 
  17271.  Before%>0 
  17272. re_sequence(fields%,Before%,-1)
  17273. selected(createW%,55) 
  17274.  mandatory%?Before%=1 
  17275.  mandatory%?Before%=0
  17276. selected(createW%,63) 
  17277.  displayit%?Before%=1 
  17278.  displayit%?Before%=0
  17279.  menflag% 
  17280. copy_menu_file
  17281. 1G    ok%=
  17282. copy_menu_file
  17283.  field%,f$,d%,F,tag$,m$,forbidden$,I%,P%
  17284.  Before%=0 
  17285.  field%=fields% 
  17286.  field%=Before%
  17287. forbidden$=" $&%@\^:.#*|"
  17288.  menufield%=0 
  17289. 1OB  menufield%=
  17290. ($TagText%):
  17291.  menufield%=0 
  17292.  menufield%=field%-1
  17293. 1Q&V$=vtype$(chartype%(menufield%))  
  17294.  V$<>"E" 
  17295.  V$<>"L" 
  17296.  Tag$(field%)="":$TagText%="":
  17297.  moan_err%,
  17298. msg("Err148")
  17299. 1SN$TagText%=Tag$(menufield%):Tag$(field%)=$TagText%:
  17300. redraw_icon(createW%,5)
  17301. m$=Tag$(menufield%)
  17302.  I%=1 
  17303.   P%=
  17304. forbidden$,
  17305. m$,I%,1))
  17306.  P%>0 
  17307. m$,I%,1)="_" 
  17308.  "OS_File",8,$database%+".Menus"
  17309. 1Z%f$=$database%+".Menus."+m$+"Menu"
  17310.  "OS_File",5,f$ 
  17311.  d%=0 
  17312.  oldmenu% 
  17313. 1^J    
  17314.  "OS_CLI","Copy <Pbase$Dir>.Resources.UserMenu "+f$+" ~CF~V"
  17315. 1`$    
  17316.  "OS_File",5,oldmenu$ 
  17317. 1a6    
  17318.  d%=1 
  17319.  "OS_CLI","Rename "+oldmenu$+" "+f$
  17320. snap(
  17321.  y%,int%)
  17322.  X%,Y%
  17323.  snapgrid%=
  17324.  int%>0 
  17325. 1i5  X%=(x% 
  17326.  int%)*int%:
  17327.  x%-X%>int% 
  17328.  X%+=int%
  17329. 1j5  Y%=(y% 
  17330.  int%)*int%:
  17331.  Y%-y%>int% 
  17332.  Y%-=int%
  17333.   $boxX%=
  17334. (X%):$boxY%=
  17335.   x%=X%:y%=Y%
  17336. snap_all
  17337.  ic%,x%,y%,w%,h%
  17338.  ic%=0 
  17339.  2*fields%-1
  17340. 1s)  !iconblock%=mainW%:iconblock%!4=ic%
  17341. 1t(  
  17342.  "Wimp_GetIconState",,iconblock%
  17343. 1u&  x%=iconblock%!8:y%=iconblock%!12
  17344. 1v-  w%=iconblock%!16-x%:h%=iconblock%!20-y%
  17345. 1w   
  17346. snap(x%,y%,
  17347. ($Gridsnap%))
  17348. 1x)  iconblock%!8=x%:iconblock%!16=x%+w%
  17349. 1y*  iconblock%!12=y%:iconblock%!20=y%+h%
  17350.   iconblock%!4=mainW%
  17351. 1{>  !block%=mainW%:block%!4=ic%:
  17352.  "Wimp_DeleteIcon",,block%
  17353. 1|(  
  17354.  "Wimp_CreateIcon",,iconblock%+4
  17355. redraw(mainW%)
  17356. nudge(b%,ic%)
  17357.  int%,z%
  17358.  b%=4 
  17359.  z%=1 
  17360.  z%=-1
  17361.  snapgrid% 
  17362.  int%=
  17363. ($Gridsnap%) 
  17364.  int%=2
  17365. -!iconblock%=mainW%:iconblock%!4=oldfield%
  17366.  "Wimp_GetIconState",,iconblock%
  17367. $x%=iconblock%!8:y%=iconblock%!12
  17368. +w%=iconblock%!16-x%:h%=iconblock%!20-y%
  17369.  ic% 
  17370.  50:y%+=int%*z%
  17371.  51:y%-=int%*z%
  17372.  52:x%+=int%*z%
  17373.  53:x%-=int%*z%
  17374. 'iconblock%!8=x%:iconblock%!16=x%+w%
  17375. (iconblock%!12=y%:iconblock%!20=y%+h%
  17376. iconblock%!4=mainW%
  17377. B!block%=mainW%:block%!4=oldfield%:
  17378.  "Wimp_DeleteIcon",,block%
  17379.  "Wimp_ForceRedraw",mainW%,x%-int%,y%-int%,x%+w%+int%*2,y%+h%+int%*2
  17380.  "Wimp_CreateIcon",,iconblock%+4
  17381.  (oldfield% 
  17382.  2)=0 
  17383.  x%+=w%:w%=0:h%=0
  17384. 7$boxX%=
  17385. (x%):$boxY%=
  17386. (y%):$boxW%=
  17387. (w%):$boxH%=
  17388.  ic%=7 
  17389. redraw_icon(createW%,ic%)
  17390. adjust_field(b%)
  17391.  Dptr%,Fptr%,L%,dflg%,deficit%,extra%
  17392.  "Wimp_GetPointerInfo",,block%
  17393.  newx%=!block%:newy%=block%!4
  17394. #Fieldnumber%=
  17395. get_field(ficon%)
  17396.  (ficon% 
  17397.  2)=0 
  17398. C  !block%=mainW%:block%!4=ficon%:
  17399.  "Wimp_GetIconState",,block%
  17400. .  Dptr%=block%!28:Desc$=$Dptr%:L%=
  17401. (Desc$)
  17402.  L%=0 
  17403.  dflg%=(winback%<<28)+&701A711 
  17404.  dflg%=(winback%<<28)+&701A731
  17405.  "Wimp_DeleteIcon",,block%
  17406.  "Wimp_GetWindowState",,block%
  17407. -  x%=block%!20-block%!4+newx%-oldx%+minx%
  17408. .  y%=block%!24-block%!16+miny%+newy%-oldy%
  17409. snap(x%,y%,
  17410. ($Gridsnap%))
  17411. f  desc%(Fieldnumber%)=
  17412. create_icon(0,mainW%,x%,y%,
  17413. string_width(Desc$),44,dflg%,"",Dptr%,hand%,L%)
  17414. C  !block%=mainW%:block%!4=ficon%:
  17415.  "Wimp_GetIconState",,block%
  17416.   Fptr%=block%!28
  17417. $    
  17418.  "Wimp_DeleteIcon",,block%
  17419. (    
  17420.  "Wimp_GetWindowState",,block%
  17421. #    x%=block%!20-block%!4+minx%
  17422. 0    y%=block%!24-block%!16+miny%+newy%-oldy%
  17423. "    
  17424. snap(x%,y%,
  17425. ($Gridsnap%))
  17426. F    width%=maxx%-minx%+newx%-oldx%:height%=maxy%-miny%+oldy%-newy%
  17427. '    keepwith%=
  17428. selected(prefsW%,16)
  17429.  keepwith% 
  17430. I      !block%=mainW%:block%!4=ficon%-1:
  17431.  "Wimp_GetIconState",,block%
  17432. 2      Dptr%=block%!28:Desc$=$Dptr%:L%=
  17433. (Desc$)
  17434. P      
  17435.  L%=0 
  17436.  dflg%=(winback%<<28)+&701A711 
  17437.  dflg%=(winback%<<28)+&701A731
  17438. &      
  17439.  "Wimp_DeleteIcon",,block%
  17440.         
  17441. C    !block%=mainW%:block%!4=ficon%:
  17442.  "Wimp_DeleteIcon",,block%
  17443.  keepwith% 
  17444. &      dwidth%=
  17445. string_width(Desc$)
  17446. *      
  17447.  "Wimp_GetWindowState",,block%
  17448. 9      x%=block%!20-block%!4+newx%-oldx%+minx%-dwidth%
  17449. 2      y%=block%!24-block%!16+miny%+newy%-oldy%
  17450. $      
  17451. snap(x%,y%,
  17452. ($Gridsnap%))
  17453. _      desc%(Fieldnumber%)=
  17454. create_icon(0,mainW%,x%,y%+2,dwidth%,44,dflg%,"",Dptr%,hand%,L%)
  17455.         
  17456. (    
  17457.  "Wimp_GetWindowState",,block%
  17458. /    x%=block%!20-block%!4+newx%-oldx%+minx%
  17459. 0    y%=block%!24-block%!16+miny%+newy%-oldy%
  17460. "    
  17461. snap(x%,y%,
  17462. ($Gridsnap%))
  17463. .    width%=maxx%-minx%:height%=maxy%-miny%
  17464. (  fieldtype%=chartype%(Fieldnumber%)
  17465.   L%=4
  17466.  fieldtype% 
  17467. -    
  17468.  40:$Fptr%="file_ff9":valptr%=1:L%=8
  17469. :    
  17470.  59:valptr%=SHlogoptr%::$Fptr%=Tag$(Fieldnumber%)
  17471.  64,65,66,67:
  17472. 4    deficit%=(height%-6) 
  17473.  44:extra%=44-deficit%
  17474. 1    
  17475.  deficit%>0 
  17476.  height%+=extra%:y%-=extra%
  17477. #    valptr%=hvalid%(fieldtype%)
  17478. %    
  17479. :valptr%=hvalid%(fieldtype%)
  17480. b  field%(Fieldnumber%)=
  17481. icon_design(Fieldnumber%,fieldtype%,x%,y%,width%,height%,valptr%,L%,
  17482. @$boxX%=
  17483. (x%):$boxY%=
  17484. (y%):$boxW%=
  17485. (width%):$boxH%=
  17486. (height%)
  17487. !block%=mainW%
  17488.  "Wimp_GetWindowState",,block%
  17489.  "Wimp_ForceRedraw",-1,block%!4,block%!8,block%!12,block%!16
  17490. swap_fields(F1%,F2%)
  17491.  F2%>0 
  17492.  F2%<=fields% 
  17493.  desc%(F1%),desc%(F2%)
  17494.  Tag$(F1%),Tag$(F2%)
  17495.  field%(F1%),field%(F2%)
  17496.  len%(F1%),len%(F2%)
  17497.  chartype%(F1%),chartype%(F2%)
  17498.  fix%(F1%),fix%(F2%)
  17499.  calc$(F1%),calc$(F2%)
  17500. re_sequence(F1%,F2%,Z%)
  17501. jD%=desc%(F1%):T$=Tag$(F1%):F%=field%(F1%):L%=len%(F1%):C%=chartype%(F1%):f%=fix%(F1%):Calc$=calc$(F1%)
  17502.  I%=F1%+Z% 
  17503.  F2% 
  17504.   desc%(I%-Z%)=desc%(I%):Tag$(I%-Z%)=Tag$(I%):field%(I%-Z%)=field%(I%):len%(I%-Z%)=len%(I%):chartype%(I%-Z%)=chartype%(I%):fix%(I%-Z%)=fix%(I%):calc$(I%-Z%)=calc$(I%)
  17505. jdesc%(F2%)=D%:Tag$(F2%)=T$:field%(F2%)=F%:len%(F2%)=L%:chartype%(F2%)=C%:fix%(F2%)=f%:calc$(F2%)=Calc$
  17506. icon_design(field%,char%,x%,y%,w%,h%,val%,len%,new%)
  17507.  flags%,bit%,V%
  17508.  design% 
  17509.  bit%=&8000 
  17510.  bit%=&1000
  17511.  char% 
  17512.  9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30:
  17513. F  !block%=keypadW%:block%!4=char%-9:
  17514.  "Wimp_GetIconState",,block%
  17515. 2  w%=block%!16-block%!8:h%=block%!20-block%!12
  17516.   flags%=&1E00253F 
  17517.  bit%
  17518.  Keypad buttons. Get w% & h% direct from keypad
  17519.  char% 
  17520.  13,14:
  17521.  design% 
  17522.  flags%=&1E00253F
  17523.  0,1,2,3,4,5,6,7,8,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:
  17524. E    
  17525.  hide%?field%=1:flags%=&00A535+(winback%<<24)+(winback%<<28)
  17526. ;    
  17527.  mandatory%?field%=1:flags%=&00A535+(fcol%(9)<<24)
  17528. :flags%=&0700A535
  17529.  21:$Fptr%="Rotate":len%=7:flags%=&1700253D 
  17530.  bit%
  17531.  27:flags%=&1700253D 
  17532.  bit%
  17533.  Tools%=1 
  17534.  $Fptr%="List values":len%=12 
  17535.  $Fptr%="Table":len%=6
  17536. 2    "  
  17537.  28:flags%=&1700253D 
  17538.  bit%
  17539.  Tools%=1 
  17540.  $Fptr%="Force update":len%=13 
  17541.  $Fptr%="Update":len%=7
  17542.  31:w%=48:h%=48:flags%=&1700253B 
  17543.  bit%
  17544.  32:$Fptr%="Print":len%=6:w%=112:h%=48:flags%=&1700253D 
  17545.  bit%
  17546.  33:w%=44:h%=44:flags%=&1700253B 
  17547.  bit%
  17548.  34:$Fptr%="Exit":len%=5:w%=112:h%=48:flags%=&1700253D 
  17549.  bit%
  17550.  35,44:w%=Buttonwidth%*2:h%=84-WithLeaf%*30:flags%=(&1700213F+WithLeaf%*16) 
  17551.  bit%
  17552.  36,37,38:w%=48:h%=48:flags%=&1700253F 
  17553.  bit%
  17554.  39:flags%=&0700A535
  17555.  40:$Fptr%="file_ff9":val%=1:flags%=&0700A53E:len%=8:
  17556.  present%=7 
  17557.  Rf%(field%)=
  17558. create_anchor("Picture"+
  17559. (field%))
  17560.  41,42,43,61,62:w%=52:h%=52:flags%=&1700253B 
  17561.  bit%
  17562.  45:$Fptr%="Quit":len%=5:w%=112:h%=48:flags%=&1700253D 
  17563.  bit%
  17564.  59:flags%=&0000A139-logosloaded%+(winback%<<28)
  17565.  60::w%=84:h%=84:flags%=&1700213F 
  17566.  bit%
  17567.  64,65,66,67:flags%=&1700A024
  17568.  w%=0 
  17569.  h%=0 
  17570.  flags%=0
  17571.  new% 
  17572.  SHformptr%=
  17573. claim_page(formanchor%,Fptr%-SHformptr%+len%+4)
  17574. Hicon%=
  17575. create_icon(0,mainW%,x%,y%,w%,h%,flags%,"",Fptr%,val%,len%+1)
  17576.  new% 
  17577.  Fptr%+=len%+4
  17578. =icon%
  17579. get_field(ic%)
  17580.  F%+=1
  17581.  field%(F%)=ic% 
  17582.  desc%(F%)=ic% 
  17583.  F%>fields%
  17584. adjust_on(on%)
  17585. design%=on%:adjust%=on%
  17586. lit(designM%,7,on%)
  17587. lit(designM%,2,
  17588.  on%)
  17589. lit(designM%,3,
  17590.  on%)
  17591. lit(designM%,4,
  17592.  on%)
  17593. lit(designM%,5,
  17594.  on%)
  17595. shade(createW%,6,
  17596.  on%)
  17597.  on% 
  17598. kill_scrollers(
  17599. close_window(keypadW%)
  17600. 20(  w%=ScreenWidth%*2:h%=MaxFields%*64
  17601. 214  !block%=0:block%!4=-h%:block%!8=w%:block%!12=0
  17602. 22'  
  17603.  "Wimp_SetExtent",mainW%,block%
  17604.  F%=1 
  17605.  fields%
  17606. 25   
  17607.  vtype$(chartype%(F%)) 
  17608.  "K","O","T","X":
  17609. 271    
  17610. icon_bit(15,mainW%,field%(F%),
  17611.  adjust%)
  17612. 28/    
  17613. icon_bit(12,mainW%,field%(F%),adjust%)
  17614. close_window(markW%):markpane%=
  17615. :ShowTools%=
  17616. change_length(NL%,msg%)
  17617.  EX%,klm%,S$,N%
  17618. EX%=NL%-RA%
  17619.  EX%=0 
  17620. 2B-SHmarkptr%=
  17621. claim_page(markanchor%,NL%+4)
  17622. 2C*dbasehandle%=
  17623. ($database%+".Database")
  17624. readsmarray(dbasehandle%,RA%)
  17625.  msg%:
  17626. extend_dbase
  17627.  (EX%>0):
  17628. confirm(
  17629. msg("Err204,"+
  17630. (RA%)+","+
  17631. (NL%)))=
  17632. extend_dbase
  17633.  (EX%<0):
  17634. confirm(
  17635. msg("Err205,"+
  17636. (RA%)+","+
  17637. (NL%)))=
  17638. shorten_dbase
  17639. $Records%=
  17640. (RA%):N%=RA%
  17641. writesmarray(dbasehandle%,N%)
  17642. close_file(dbasehandle%)
  17643.  msg% 
  17644.  addr=
  17645. moveto(key%,top,1)
  17646. renew_tables
  17647. extend_dbase
  17648.  end%,P%,I%,key%,keybase%,KLM%,S$
  17649.  key%=0 
  17650.  Keys%
  17651.   S$=
  17652. KL%(key%),".")
  17653.   KLM%=KL%(key%)+13
  17654.   P%=LH%+48+(NL%+1)*KLM%
  17655. 2YF  SHkeyptr%(key%)=
  17656. extend_named_sliding_block(keyanchor%(key%),P%)
  17657.   keybase%=SHkeyptr%(key%)
  17658.   P%=LH%+48+RA%*KLM%
  17659.  I%=RA% 
  17660.  EX%+RA%-1
  17661.     !(keybase%+P%)=P%+KLM%
  17662.     !(keybase%+P%+4)=0
  17663.     $(keybase%+P%+8)=S$
  17664. 2`%    !(keybase%+P%+KL%(key%)+9)=I%
  17665.     P%+=KLM%
  17666.   !(keybase%+P%)=0
  17667.   !(keybase%+P%+4)=0
  17668.   $(keybase%+P%+8)=S$
  17669. 2f"  !(keybase%+P%+KL%(key%)+9)=0
  17670.  key%
  17671. end%=(RA%+1)*Length%
  17672.  "Hourglass_On"
  17673.  I%=0 
  17674.  EX%-1
  17675. 2k$  
  17676. #dbasehandle%=end%+I%*Length%
  17677.  J%=1 
  17678.  fields%
  17679. #dbasehandle%,""
  17680. 2o.  
  17681.  "Hourglass_Percentage",(I%*100) 
  17682.  "Hourglass_Off"
  17683. RA%=NL%
  17684. #dbasehandle%=(RA%+1)*Length%
  17685. shorten_dbase
  17686.  P%,L%,R%,s$,key%,keybase%,S$
  17687.  key%=0 
  17688.  Keys%
  17689.   S$=
  17690. KL%(key%),".")
  17691.   KLM%=KL%(key%)+13
  17692.   keybase%=SHkeyptr%(key%)
  17693. 2|$  s$=$(keybase%+LH%+56+NL%*KLM%)
  17694. 2}]  
  17695.  s$<>S$ 
  17696. close_file(dbasehandle%):
  17697.  "Wimp_CreateMenu",,-1:
  17698.  moan_err%,
  17699. msg("Err52")
  17700.   P%=LH%+48+NL%*KLM%
  17701.   !(keybase%+P%)=0
  17702.   !(keybase%+P%+4)=0
  17703.   $(keybase%+P%+8)=S$
  17704. "  !(keybase%+P%+KL%(key%)+9)=0
  17705.  key%
  17706. RA%=NL%
  17707. #dbasehandle%=(RA%+1)*Length%
  17708. copy_database_spritefile(path$,leaf$)
  17709.  SHappsprite%
  17710. BSHappsprite%=
  17711. extend_named_sliding_block(sprsanchor%,SHclaim%)
  17712.  ### This is a temporary sprite area used simply to hold ###
  17713.  ### the sprite 'new_appl' whilst it is renamed and saved ###
  17714. !SHappsprite%=2600
  17715. SHappsprite%!8=16
  17716.  ### Initialise sprite area ###
  17717.  "OS_SpriteOp",&109,SHappsprite%
  17718.  ### Load !Sprites file from Resources ###
  17719.  "OS_SpriteOp",&10A,SHappsprite%,"<PBase$Dir>.Resources.Temp.!Sprites"
  17720.  ### Rename sprite 'new_appl' to new database name ###
  17721.  "OS_SpriteOp",&11A,SHappsprite%,"new_appl",leaf$
  17722.  ### Save spritefile (with renamed new_appl) as !Sprites ###
  17723.  "OS_SpriteOp",&10C,SHappsprite%,path$+".!Sprites"
  17724.  ### Do same for hi-res sprite ###
  17725.  "OS_SpriteOp",&109,SHappsprite%
  17726.  "OS_SpriteOp",&10A,SHappsprite%,"<PBase$Dir>.Resources.Temp.!Sprites22"
  17727.  "OS_SpriteOp",&11A,SHappsprite%,"new_appl",leaf$
  17728.  "OS_SpriteOp",&10C,SHappsprite%,path$+".!Sprites22"
  17729. scrap_block(sprsanchor%)
  17730. rename_database(name$)
  17731.  SHappsprite%,len%
  17732. name$=
  17733. force_pling(name$)
  17734.  "OS_File",5,$database%+".!Sprites22" 
  17735.  ,,,,len%
  17736. BSHappsprite%=
  17737. extend_named_sliding_block(sprsanchor%,len%+100)
  17738. !SHappsprite%=len%+100
  17739. SHappsprite%!8=16
  17740.  "OS_SpriteOp",&109,SHappsprite%
  17741.  "OS_SpriteOp",&10A,SHappsprite%,$database%+".!Sprites"
  17742.  "OS_SpriteOp",&11A,SHappsprite%,"!"+$dbase%,name$
  17743.  "OS_SpriteOp",&10C,SHappsprite%,$database%+".!Sprites"
  17744.  "OS_SpriteOp",&109,SHappsprite%
  17745.  "OS_SpriteOp",&10A,SHappsprite%,$database%+".!Sprites22"
  17746.  "OS_SpriteOp",&11A,SHappsprite%,"!"+$dbase%,name$
  17747.  "OS_SpriteOp",&10C,SHappsprite%,$database%+".!Sprites22"
  17748. iconbar_icon(
  17749. name$,2))
  17750. scrap_block(sprsanchor%)
  17751. #$Title%=name$:
  17752. redraw(keypadW%)
  17753. old$=
  17754. leaf($database%)
  17755. !name$=leafnamepath$+"."+name$
  17756.  "OS_CLI","Rename "+$database%+" "+name$
  17757. $database%=name$
  17758.  logging% 
  17759.  "OS_CLI","Unset Log$Dir":
  17760. read_sys_vars($database%)
  17761. write_log(-1,"Database renamed:",old$+"---> "+
  17762. leaf(name$))
  17763. defaults(f$,N%,key%)
  17764. ?abort%=
  17765. confirm(
  17766. msg("Err133,"+
  17767. (N%)+","+Tag$(KF%(0,0))))
  17768.  abort% 
  17769. $Records%=
  17770. make_empty_index(N%,key%,
  17771. save_recs(f$+".Database",N%)
  17772. %present%=7:
  17773. save_keys:
  17774. save_calcs
  17775. 2design%=
  17776. :present%=1:
  17777. get_it_in(f$):ramwarn%=
  17778. lit(iconbarM%,2,
  17779. default_key
  17780. first_writable
  17781.  chartype%(F%) 
  17782.  3,6,46,47,54,56,57,74,75,77,78,79:KL%(0)=len%(F%)
  17783.  len%(F%)>3 
  17784.  KL%(0)=4 
  17785.  KL%(0)=len%(F%)
  17786. key%=0
  17787. KW%()=0:KF%()=0
  17788. 0KW%(0,0)=KL%(0)+(1<<16)+(F%<<24):KF%(0,0)=F%
  17789. set_keydata(key%)
  17790. new_tree(f%)
  17791.  REC%,ptr%,file%,old$,new$
  17792. old$=
  17793. key_structure
  17794. selected(keyW%,33):s%=
  17795. selected(keyW%,32)
  17796.  f%=0
  17797. M$="Build index with "
  17798.  M$+="records in same subfiles" 
  17799.  M$+="all records in subfile "+
  17800. M$+=" of current database"
  17801.  M$+=", also restoring 'deleted' records."
  17802.  M$+=" WARNING! Other indexes will need rebuilding!"
  17803. confirm(M$)=
  17804. =SHmisc%=
  17805. extend_named_sliding_block(tempanchor%,SHclaim%)
  17806. mark_files(SHmisc%,0,RA%,
  17807.  d%,s%,f%)
  17808. copy_keydata(0)
  17809.  "OS_File",5,$database%+".Database" 
  17810.  ,,,,len%
  17811. RA%=(len% 
  17812.  Length%)-1
  17813. scrap_block(keyanchor%(0))
  17814. make_empty_index(RA%,0,
  17815. close_window(keyW%)
  17816. redraw(keypadW%)
  17817. %SHmisc%=!tempanchor%:ptr%=SHmisc%
  17818. duplicates%=0
  17819.  "Hourglass_On"
  17820. *dbasehandle%=
  17821. ($database%+".Database")
  17822.  REC%=0 
  17823.  RA%-1
  17824.   file%=ptr%?REC%
  17825.  file%<>255 
  17826.     top=8*file%+LH%
  17827. '    
  17828. readsmarray(dbasehandle%,REC%)
  17829.     KEY$=
  17830. key2(0,1)
  17831.      K$=
  17832. stripright(KEY$," ")
  17833.  K$<>"" 
  17834.       
  17835. insert(KEY$,0,
  17836.       
  17837.       
  17838. %        
  17839. close_file(dbasehandle%)
  17840. 5        
  17841. load_index($database%+".PrimaryKey",0,
  17842. &        
  17843.  moan_err%,
  17844. msg("Err111")
  17845.         
  17846.  ptr%?REC%=255
  17847.       
  17848.         
  17849.  "Hourglass_Percentage",(REC%*100) 
  17850.  REC%
  17851. close_file(dbasehandle%)
  17852. Vkeybase%=SHkeyptr%(0):nextfree%=!keybase%:nodesize%=12+KL%(0)+1:offset%=8+KL%(0)+1
  17853.  REC%=0 
  17854.  RA%-1
  17855.  ptr%?REC%=255 
  17856. *    !(keybase%+nextfree%+offset%)=REC%
  17857.     nextfree%+=nodesize% 
  17858.  REC%
  17859. "newtree%=
  17860. :design%=
  17861. :adjust%=
  17862.  "Hourglass_Off"
  17863.  duplicates%>0 
  17864. softerror(
  17865. (duplicates%),175)
  17866. present%=7
  17867. new$=
  17868. key_structure
  17869. refresh_pointers
  17870. write_log(-1,"Primary key structure altered. Was: "+old$,"Changed to: "+new$)
  17871.  "Wimp_CreateMenu",,-1
  17872. 3file%=0:top=8*file%+LH%:
  17873. asterisk(
  17874. ):ramwarn%=
  17875. renew_tables
  17876. get_it_in($database%):ramwarn%=
  17877. key_structure
  17878.  I%,W%,chars%,pos%,word%,c$,p$,w$,struc$
  17879.  I%=0 
  17880.   W%=KW%(0,I%)
  17881.  W%>0 
  17882. $    chars%=W% 
  17883.  255:c$=
  17884. (chars%)
  17885. M    pos%=(W%>>8) 
  17886.  255:p$=
  17887. (pos%):
  17888.  pos%=0 
  17889.  p$="L" 
  17890.  pos%=255 
  17891.  p$="R"
  17892. (    word%=(W%>>16) 
  17893.  255:w$=
  17894. (word%)
  17895. :    struc$+=Tag$(KF%(0,I%))+" ("+w$+","+p$+","+c$+"),"
  17896. struc$)
  17897. reformat(f$)
  17898.  I%,J%,F,REC%,dfields%,DLength%,newhandle%,z%,key%,then%,now%,path$,F$,C%,col%,col2%
  17899.  DTag$(),F%(),F1%(),L%(),V%(),l$(),c$()
  17900.  f$ will become reformatted database
  17901.  Original database is open during this function
  17902. F$(0)=""
  17903.  "OS_File",5,f$+".Form" 
  17904.  z%<>1 
  17905. softerror("",19):=
  17906. store_menu_inf
  17907. copy_files($database%,f$)
  17908. (f$+".Form")
  17909. #F,dfields%
  17910.  DTag$(dfields%),F%(dfields%),F1%(fields%),L%(dfields%),V%(dfields%),l$(dfields%),c$(dfields%)
  17911.  I%=1 
  17912.  dfields%
  17913. 3-E  
  17914. #F,Desc$,DTag$(I%),xd%,yd%,xf%,yf%,L%(I%),V%(I%),extra%,extra%
  17915. 3.+  
  17916.  V%(I%)=33 
  17917.  DTag$(I%)="!"+DTag$(I%)
  17918. 3/%  
  17919.  L%(I%)>0 
  17920.  DLength%+=L%(I%)+1
  17921. close_file(F)
  17922. compare 
  17923. selected(reformW%,11) 
  17924. position_window(informW%,0,0,0,0,0,0)
  17925. complete(2)
  17926. 35 newhandle%=
  17927. (f$+".Database")
  17928. 36,dbasehandle%=
  17929. ($database%+".Database")  
  17930.  "Hourglass_On"
  17931.  REC%=0 
  17932. 39   
  17933. #newhandle%=REC%*DLength%
  17934. 3:%  
  17935. readsmarray(dbasehandle%,REC%)
  17936.  I%=1 
  17937.  dfields%
  17938.     S$=F$(F%(I%))
  17939.  V%(I%) 
  17940.       
  17941.  5,50,51,70,71:
  17942.       
  17943. 3@2        
  17944.  S$="":
  17945.  Date field blank; do nothing
  17946. 3A2        
  17947. (S$)=10 
  17948.  L%(I%)=8:S$=
  17949. S$,6)+
  17950. S$,2)
  17951. 3B"        
  17952. (S$)=8 
  17953.  L%(I%)=10:
  17954.         y$=
  17955. S$,2):y%=
  17956. 3D6        
  17957.  y%<CentChange% 
  17958.  y$="20"+y$ 
  17959.  y$="19"+y$
  17960.         S$=
  17961. S$,6)+y$
  17962.       
  17963.       
  17964.  64,65,66,67:
  17965. 3H9      
  17966.  V%() holds destination database's field-types
  17967. 3I2      
  17968.  chartype%() holds original field-types
  17969. 3J6      Scols%=chartype%(F%(I%))-63:Dcols%=V%(I%)-63
  17970.       
  17971.  Scols%<>Dcols% 
  17972. 3L5        L%=
  17973. blob_path(
  17974. ,f$,REC%,F%(I%),V%(I%),b$)
  17975.         
  17976.  L%>0 
  17977. 3N0          old%=
  17978. (b$):temp%=
  17979. ("<Wimp$Scrap>")
  17980.           
  17981. #old%
  17982. 3P#            F$=
  17983. #old%:col%=C%+1
  17984.             
  17985. 3R,              
  17986.  col%>Dcols%:
  17987.  Do nothing
  17988. 3S5              
  17989.  col%=Scols%:
  17990. #temp%,F$:col2%=col%
  17991. 3T!              
  17992.  col2%<Dcols%
  17993. 3U'                
  17994. #temp%,"":col2%+=1
  17995.               
  17996. 3W+              
  17997.  col%<=Dcols%:
  17998. #temp%,F$
  17999.             
  18000. 3Y"            C%=(C%+1) 
  18001.  Scols%
  18002.           
  18003. 3[2          
  18004. close_file(old%):
  18005. close_file(temp%)
  18006. 3\:          
  18007.  "OS_CLI","Copy <Wimp$Scrap> "+b$+" ~C~VF"
  18008.         
  18009.       
  18010. 3_        
  18011. 3`'    
  18012. (S$)>L%(I%) 
  18013. S$,L%(I%))
  18014. 3a$    
  18015.  L%(I%)>0 
  18016. #newhandle%,S$
  18017. 3c0  
  18018.  "Hourglass_Percentage",(REC%*100) 
  18019.  REC%
  18020.  "OS_CLI","Remove <Wimp$Scrap>"
  18021.  "Hourglass_Off"
  18022. close_file(newhandle%)
  18023. close_file(dbasehandle%)
  18024.  "OS_File",18,f$+".Database",&fff
  18025.  link$(0)="LOADED" 
  18026. (f$+".Link")
  18027.  F%=1 
  18028.  dfields%
  18029. #F,l$(F%)
  18030. close_file(F)
  18031.  calc$(0)="LOADED" 
  18032. (f$+".Calc")
  18033.  F%=1 
  18034.  dfields%
  18035. #F,c$(F%)
  18036. close_file(F)
  18037.  key%=0 
  18038.  Keys%
  18039. 3yK  
  18040.  key%=0 
  18041.  path$=f$+".PrimaryKey" 
  18042.  path$=f$+".Indexes."+Index$(key%)
  18043. (path$)
  18044. #F=74
  18045.  J%=0 
  18046.     then%=KW%(key%,J%)>>24
  18047. 3~,    
  18048.  then%>0 
  18049.  now%=F1%(then%) 
  18050.  now%=0
  18051. #F=74+3+J%*4
  18052.      
  18053.  now%<>then% 
  18054. #F,now%
  18055. close_file(F)
  18056.  key%
  18057. close_window(reformW%)
  18058. close_it(informW%)
  18059. asterisk(
  18060. write_log(-1,"Record structure changed","")
  18061. compare
  18062.  source%,dest%,del$,short$,col$
  18063.  source%=1 
  18064.  fields%
  18065.  chartype%(source%)=33 
  18066.  Tag$(source%)="!"+Tag$(source%)
  18067.   dest%=dfields%+1
  18068.     dest%-=1
  18069.  dest%=0 
  18070.  DTag$(dest%)=Tag$(source%)
  18071. *  F%(dest%)=source%:F1%(source%)=dest%
  18072.  dest%=0 
  18073.     del$+=Tag$(source%)+"\"
  18074.         
  18075.      l$(dest%)=link$(source%)
  18076.      c$(dest%)=calc$(source%)
  18077.  chartype%(source%) 
  18078.       
  18079.  64,65,66,67:
  18080. B      
  18081.  V%(dest%)<chartype%(source%) 
  18082.  col$+=Tag$(source%)+"\"
  18083. A      
  18084.  L%(dest%)<len%(source%) 
  18085.  short$+=Tag$(source%)+"\"
  18086.         
  18087.  source%
  18088.  del$<>"" 
  18089. confirm(
  18090. msg("Err97,"+
  18091. del$))) 
  18092.  short$<>"" 
  18093. confirm(
  18094. msg("Err117,"+
  18095. short$))) 
  18096.  col$<>"" 
  18097. confirm(
  18098. msg("Err177,"+
  18099. col$))) 
  18100. merge_files(merge$,new$,fi%)
  18101.  R%,REC%,ptr%,file%,d%,s%,z%,RUM%,RAM%,NL%,ex%,blobs%
  18102.  new$<>$database% 
  18103.  "OS_CLI","Copy "+$database%+" "+new$+" ~C ~V R"
  18104. get_it_in(new$)
  18105. text(mergebaseW%,2)=$database%:
  18106. redraw_icon(mergebaseW%,2)
  18107.  "OS_File",5,merge$+".Database" 
  18108.  z%<>1:
  18109. softerror("",29)
  18110.  merge$=$database%:
  18111. softerror("",15)
  18112. identical(merge$):
  18113. softerror("",21)
  18114. ?  s%=
  18115. selected(mergebaseW%,11):d%=
  18116. selected(mergebaseW%,12)
  18117.  fi%=0
  18118. !  M$="Merge "+merge$+" with "
  18119.  M$+="corresponding subfiles" 
  18120.  M$+="subfile "+
  18121. (fi%)
  18122.    M$+=" of current database"
  18123.  M$+=", also restoring deleted records"
  18124.  M$+=". WARNING! indexes will need rebuilding!"
  18125. confirm(M$)=
  18126. 4    
  18127.  "OS_File",5,merge$+".Database" 
  18128.  ,,,,len%
  18129.     RAM%=(len% 
  18130.  Length%)-1
  18131. I    
  18132.  ### Load primary key of file to be merged into a spare slot ###
  18133. 6    
  18134. load_index(merge$+".PrimaryKey",MaxKeys%+1,
  18135. @    
  18136.  ### Mark which subfile each new record is to go in ###
  18137. =    SHmisc%=
  18138. extend_named_sliding_block(tempanchor%,RAM%)
  18139. 8    
  18140. mark_files(SHmisc%,MaxKeys%+1,RAM%,
  18141.  d%,s%,fi%)
  18142. &    keybase%=SHkeyptr%(MaxKeys%+1)
  18143. F    
  18144.  ### Count how many record actually used in file to merge ###
  18145. -    
  18146. count(MaxKeys%+1,RUM%):
  18147. count(0,RU%)
  18148. *    
  18149.  NL%=RU%+RAM% 
  18150.  NL%=RU%+RUM%
  18151.  "Hourglass_On"
  18152. O    
  18153.  ### Expand existing file if new length (NL%) exceeds availability ###
  18154. )    
  18155.  NL%>RA% 
  18156. change_length(NL%,
  18157. &    blobs%=
  18158. find_blobs($database%)
  18159. )    SHmisc%=!tempanchor%:ptr%=SHmisc%
  18160.  R%=0 
  18161.  RAM%-1
  18162.       file%=ptr%?R%
  18163.       
  18164.  file%<>255 
  18165.         
  18166. make_new_rec
  18167.         top=8*file%+LH%
  18168. (        
  18169. read(
  18170. ,fields%,
  18171. ,R%,merge$)
  18172. <        
  18173. selected(mergebaseW%,10) 
  18174.  dontincrement%=
  18175.          
  18176. write(fields%,key%)
  18177.         ex%=-1
  18178.         
  18179.  ex%<blobs%
  18180. !          ex%+=1:F%=Ext%(ex%)
  18181. D          
  18182. copy_blob(merge$,$database%,R%,REC%,F%,chartype%(F%))
  18183.         
  18184. 5        
  18185.  "Hourglass_Percentage",(R%*100) 
  18186.  RUM%
  18187.       
  18188.  "Hourglass_Off"
  18189. close_it(mergebaseW%)
  18190. !    file%=fi%:top=8*file%+LH%
  18191.      addr=
  18192. moveto(key%,top,1)
  18193. asterisk(
  18194. write_log(-1,"Records merged from database:",merge$)
  18195. identical(f$)
  18196.  I%,F,dfields%,different%
  18197. (f$+".Form")
  18198. #F,dfields%
  18199.  dfields%<>fields% 
  18200.  different%=
  18201.  I%<fields% 
  18202.  different%
  18203.   I%+=1
  18204. #F,Desc$,Tag$,xd%,yd%,xf%,yf%,len%,char%,extra%,extra%
  18205.   char%=char% 
  18206.  char%<>39 
  18207.  len%<>len%(I%) 
  18208.  different%=
  18209.  char%<>chartype%(I%) 
  18210.  (char%>8 
  18211.  chartype%(I%)>8) 
  18212.  different%=
  18213. close_file(F)
  18214.  different%
  18215. mark_files(ptr%,key%,RA%,d%,s%,f%)
  18216.  P%,I%,M,file%,top
  18217.  "Hourglass_On"
  18218.  I%=0 
  18219.  RA%-1
  18220.   ptr%?I%=d%
  18221.  file%=0 
  18222.     top=8*file%+LH%
  18223. !    P%=
  18224. neighbour(key%,top,1)
  18225.  P%<>top
  18226.        S%=
  18227. rec_no(k$,key%,P%)
  18228. +      
  18229.  ptr%?S%=file% 
  18230.  ptr%?S%=f%
  18231. "      P%=
  18232. neighbour(key%,P%,1)
  18233.         
  18234.  file%
  18235.  "Hourglass_Off"                          
  18236. print_tree(key%,PR$)
  18237.  L%(),levels%(),COL%,levels%,depth%,P%,keybase%,L%,L$,M$,fi%,top,maxlevels%,total%,sym%,pos%
  18238.  levels%(5)
  18239. 4    PTextName$=$database%+".PrintJobs.Tree"+
  18240. Index$(key%),6):$SaveName%=TextName$
  18241. ticked(indextreeM%,1) 
  18242.  from%=file%:to%=file% 
  18243.  from%=0:to%=5
  18244.  "Hourglass_On"
  18245.  fi%=from% 
  18246.   top=8*fi%+LH%
  18247.   COL%=0:depth%=0
  18248. A  keybase%=SHkeyptr%(key%):P%=!(keybase%+top):
  18249. traverse(P%,
  18250.   levels%(fi%)=depth%-2
  18251.  levels%(fi%)>maxlevels% 
  18252.  maxlevels%=levels%(fi%)
  18253.  maxlevels%>127 
  18254. rectify_address(key%):
  18255.  moan_err%,
  18256. msg("Err153")
  18257.  L%(maxlevels%)
  18258.  interval%=
  18259. (2^maxlevels%))
  18260.  PR$="ALL" 
  18261.  KL%(key%)>interval% 
  18262.  interval%=KL%(key%)
  18263. interval%+=1
  18264. print_init("W")
  18265. format$="tree"
  18266. 1LenLine%=Lmargin%+(maxlevels%+1)*interval%+12
  18267.  LenLine%<30 
  18268.  LenLine%=30
  18269. %maxhead%=0:hspace%=200:fspace%=18
  18270. (Tab%(2)=12:PrintFields%=maxlevels%+2
  18271.  L%=1 
  18272.  maxlevels%+1
  18273. %  Tab%(L%+2)=Tab%(L%+1)+interval%
  18274. end_line
  18275. send_title(
  18276. send_title($dbase%+" - Tree Analysis")
  18277. send_title("Key "+
  18278. (key%)+" ("+Index$(key%)+")")
  18279. sym%=
  18280. ticked(indextreeM%,2)
  18281.  fi%=from% 
  18282.  levels%(fi%)>=0 
  18283. 4*'    pos%=TextPtr%+Lmargin%+LenLine%
  18284. store_rec_num(-2)
  18285. 4,3    
  18286. store_string("Subfile "+
  18287. (fi%),Lmargin%,
  18288. store_rec_num(-2)
  18289. end_line
  18290. 4/#    
  18291. tree_heading(levels%(fi%))
  18292.     top=8*fi%+LH%
  18293.     COL%=0:depth%=0:L%()=0
  18294. 42C    keybase%=SHkeyptr%(key%):P%=!(keybase%+top):
  18295. traverse(P%,
  18296.     total%=
  18297. (L%())
  18298.     S$=
  18299. (total%)+" node"
  18300.  total%>1 
  18301.  S$+="s"
  18302. 46%    $pos%=S$:pos%+=
  18303. (S$):?pos%=32
  18304.  PR$="ALL" 
  18305. 48     L1$=
  18306. padL("1",interval%)
  18307. store_rec_num(-2)
  18308. 4:2    
  18309. store_string("No. nodes "+L1$,Lmargin%,
  18310.     L%=0
  18311.  L%<levels%(fi%)
  18312.       L%+=1 
  18313. 4>(      L$=
  18314. padL(
  18315. (L%(L%)),interval%):
  18316. 4?6      
  18317. store_string(L$,Lmargin%+L%*interval%+10,
  18318. 4@        
  18319. end_line
  18320. store_rec_num(-2)
  18321. 4C2    
  18322. store_string("Max.nodes "+L1$,Lmargin%,
  18323.     L%=0
  18324.  L%<levels%(fi%)
  18325.       L%+=1   
  18326. 4G%      M$=
  18327. padL(
  18328. (2^L%),interval%)
  18329. 4H6      
  18330. store_string(M$,Lmargin%+L%*interval%+10,
  18331. 4I        
  18332. end_line
  18333. 4K9    
  18334.  PR$="ALL" 
  18335. tree_heading(levels%(fi%)) 
  18336.  "Hourglass_Off"
  18337. tkey%=key%
  18338. screen_list
  18339. write_log(-1,"Tree printed: subfile:"+
  18340. (fi%)+", key:"+
  18341. (key%)+", "+Index$(key%),"")
  18342. tree_heading(levels%)
  18343.  zero%,L%
  18344. store_rec_num(-2)
  18345. store_string("Level No.",Lmargin%,
  18346. padL("0",interval%)
  18347. store_string(L$,Lmargin%+10,
  18348.  L%<levels%
  18349.   L%+=1
  18350.   L$=
  18351. padL(
  18352. (L%),interval%)
  18353. 4^2  
  18354. store_string(L$,Lmargin%+L%*interval%+10,
  18355. end_line
  18356. 4b"count%=
  18357. count_recs(key%,zero%)
  18358. traverse(P%,Z%)
  18359.  string$
  18360. COL%+=1
  18361.  COL%>depth% 
  18362.  depth%=COL%
  18363.  P%<0 
  18364. read_node(keybase%+P%)
  18365.  sym% 
  18366. traverse(L%,Z%):COL%-=1:
  18367. read_node(keybase%+P%)
  18368.   L%(COL%-1)=L%(COL%-1)+1
  18369.  PR$="ALL" 
  18370. store_rec_num(rec%)
  18371.     S$=$(keybase%+P%+8)
  18372.     S$=
  18373. stripright(S$,"#")
  18374.     S$=
  18375. padL(S$,interval%)
  18376. 4s:    
  18377. store_string(S$,Lmargin%+(COL%-1)*interval%+10,
  18378.  sym% 
  18379. traverse(R%,Z%) 
  18380. traverse(L%,Z%)
  18381. COL%-=1
  18382.  sym% 
  18383. read_node(keybase%+P%):
  18384. traverse(R%,Z%):COL%=COL%-1
  18385. read_node(P%)
  18386. 4|*L%=!P%:R%=P%!4:rec%=P%!(8+KL%(key%)+1)
  18387. balance(key%)
  18388.  recptr%,top,file%,I%,N%,A%,max%,done%,highest%,avail%,seglen%,REC%,SHbalptr%,SHflag%
  18389.  recs%(),ptr%()
  18390.  recs%(5),ptr%(5)
  18391. set_keydata(key%)
  18392. -newtree%=
  18393.                                
  18394. seglen%=KL%(key%)+5
  18395. ASHrecptr%=
  18396. extend_named_sliding_block(recanchor%,seglen%*RA%)
  18397. ASHbalptr%=
  18398. extend_named_sliding_block(balanchor%,seglen%*RA%)
  18399. 8SHflag%=
  18400. extend_named_sliding_block(flaganchor%,RA%)
  18401. recptr%=SHrecptr%
  18402.  I%=0 
  18403.  RA%-1
  18404.   SHflag%?I%=255
  18405.  Bytes are changed from 255 to 0 where records are in use
  18406.  "Hourglass_On"
  18407.  file%=0 
  18408.   ptr%(file%)=recptr%
  18409.   top=8*file%+LH%
  18410. .  recs%(file%)=
  18411. count_recs(key%,recptr%)-1
  18412.   max%+=recs%(file%)+1
  18413.  file%
  18414. make_empty_index(RA%,key%,
  18415.  "Hourglass_LEDs",%11
  18416.  file%=0 
  18417.   top=8*file%+LH%
  18418.  recs%(file%)>=0 
  18419.     recptr%=ptr%(file%)
  18420.     N%=1
  18421.         
  18422.       N%=N%+N%
  18423.  N%>recs%(file%)+2
  18424.     step%=N%
  18425.     N%=(N% 
  18426.  2)-1
  18427.     start%=N%
  18428.     C%=0
  18429.         
  18430.       start%=start% 
  18431.       end%=N%-start%-1
  18432.       step%=step% 
  18433. $      
  18434.  I%=start% 
  18435.  end% 
  18436.  step%
  18437. 9        A%=recptr%+seglen%*(I%*(recs%(file%)+1) 
  18438. A        SHbalptr%!C%=!A%:$(SHbalptr%+C%+4)=$(A%+4):!A%=-!A%-1
  18439.         C%+=seglen%
  18440.       
  18441.  step%=2
  18442. %    
  18443.  I%=0 
  18444.  C%-seglen% 
  18445.  seglen%
  18446. 2      REC%=SHbalptr%!I%:KEY$=$(SHbalptr%+I%+4)
  18447.       
  18448. insert(KEY$,key%,
  18449.       done%+=1
  18450. 6      
  18451.  "Hourglass_Percentage",(done%*100) 
  18452.  max%
  18453.  I%=0 
  18454.  recs%(file%)
  18455. #      REC%=recptr%!(seglen%*I%)
  18456.       
  18457.  REC%>=0 
  18458. (        KEY$=$(recptr%+seglen%*I%+4)
  18459.          
  18460. insert(KEY$,key%,
  18461.         done%+=1
  18462. 8        
  18463.  "Hourglass_Percentage",(done%*100) 
  18464.  max%
  18465.       
  18466.  file%
  18467.  "Hourglass_LEDs",%00
  18468. keybase%=SHkeyptr%(key%)
  18469. nodesize%=8+KL%(key%)+1+4
  18470. avail%=!keybase%
  18471.  I%=0 
  18472.  highest%
  18473.  SHflag%?I%=255 
  18474. +    !(keybase%+avail%+8+KL%(key%)+1)=I%
  18475.     avail%+=nodesize%
  18476.  "Hourglass_Off"
  18477. save_keys
  18478. scrap_block(balanchor%)
  18479. scrap_block(flaganchor%)
  18480. scrap_block(recanchor%)
  18481. newtree%=
  18482. asterisk(
  18483. write_log(-1,"Index "+Index$(key%)+" balanced","")
  18484. duplicates(key%)
  18485.  P$,S$,RP$,RS$,addr,top,RP%,RS%,count%,examined%,file%,zero%
  18486. abort_dup:
  18487. print_init("W")
  18488. format$="dup"
  18489. YTextName$=$database%+".PrintJobs.Dupl"+
  18490. Index$(key%),5)+
  18491. (file%):$SaveName%=TextName$
  18492. "LenLine%=Lmargin%+KL%(key%)+21
  18493.  LenLine%<Lmargin%+26 
  18494.  LenLine%=Lmargin%+26
  18495. spacer$,"|")>0 
  18496.  spacer$="|"
  18497. NTab%(2)=14:Tab%(3)=19:maxhead%=0:fspace%=18:hspace%=4*36-18:PrintFields%=3
  18498. end_line
  18499. send_title("Duplicated keys")
  18500. send_title(
  18501.  "Hourglass_On"
  18502.  file%=0 
  18503. send_title($Subfile%(file%))
  18504.   top=8*file%+LH%
  18505. !  addr=
  18506. neighbour(key%,top,1)
  18507. 0  count%=
  18508. count_recs(key%,zero%):examined%=0
  18509.  addr<>top
  18510. $    S$=$(SHkeyptr%(key%)+addr+8)
  18511.     S$=
  18512. stripright(S$,"#")
  18513. /    RS%=!(SHkeyptr%(key%)+addr+9+KL%(key%))
  18514. ;    RS$=
  18515. (RS%):RS$="Record No."+
  18516. (RS$)," ")+RS$+"  "
  18517.  S$<>P$ 
  18518.       P$=S$:RP%=RS%:RP$=RS$
  18519.       
  18520.       
  18521. store_rec_num(RP%)
  18522. *      
  18523. store_string(RP$+P$,Lmargin%,
  18524.       
  18525. store_rec_num(RS%)
  18526. *      
  18527. store_string(RS$+S$,Lmargin%,
  18528.         
  18529.     examined%+=1
  18530. 8    
  18531.  "Hourglass_Percentage",examined%*100 
  18532.  count%
  18533. $    addr=
  18534. neighbour(key%,addr,1)
  18535.  file%
  18536.  "Hourglass_Off"
  18537. screen_list
  18538. abort_dup
  18539.  "Hourglass_Off"
  18540. screen_list
  18541. softerror("",67)
  18542. wimp_error(
  18543.  Index handling ------------------------------------------------------
  18544. neighbour(key%,addr%,d%)
  18545.  R%,S%,p%,keybase%
  18546. %SHkeyptr%(key%)=!keyanchor%(key%)
  18547. keybase%=SHkeyptr%(key%)
  18548. p%=d%*4
  18549. R%=!(keybase%+addr%+p%)
  18550.  R%<0 
  18551.  =-R%
  18552. p%=4-p%
  18553.   addr%=R%
  18554.   S%=!(keybase%+addr%+p%)
  18555.  S%>0 
  18556.  R%=S%
  18557.  S%<=0
  18558. rec_no(
  18559.  k$,key%,addr%)
  18560. !k$=$(SHkeyptr%(key%)+addr%+8)
  18561. +=!(SHkeyptr%(key%)+addr%+8+KL%(key%)+1)
  18562. scan_marked_subfiles(c$,key%,action%,direc%,currentkey%)
  18563.  file%,top
  18564.  special%(5) 
  18565. (libfunc$+"_function(5)")
  18566.  "Hourglass_On"
  18567.  file%=0 
  18568. 5"$  
  18569. selected(queryW%,file%+6) 
  18570.     top=8*file%+LH%
  18571.  currentkey% 
  18572. 5%(      P%=
  18573. neighbour(key%,top,direc%)
  18574. 5&2      
  18575. scan_file(c$,key%,file%,action%,direc%)
  18576.       
  18577.       kl%=
  18578. (useval$)
  18579. 5)$      P%=
  18580. search(useval$,key%,1)
  18581. 5*G      
  18582.  P%>=0 
  18583.  k$=useval$:
  18584. scan_file(c$,key%,file%,action%,direc%)
  18585. 5+        
  18586.  file%
  18587.  "Hourglass_Off"
  18588.  special%(6) 
  18589. (libfunc$+"_function(6)")
  18590. scan_file(c$,key%,file%,action%,direc%)
  18591.  REC%,examined%,subtotal%,X%,Y%,n$,copy%,I%,base%,zero%,end$
  18592. base%=SHmarkptr%
  18593. n$="0123456789."
  18594.  key%=usekey% 
  18595. 57-  
  18596.  direc%=1 
  18597.  end$="first" 
  18598.  end$="last"
  18599. 58T  subtotal%=
  18600. count_matches(end$,"LEFT$($(SHkeyptr%(key%)+P%+8),kl%)=useval$",P%)
  18601. 5:'  subtotal%=
  18602. count_recs(key%,zero%)
  18603. (c$)=
  18604.   REC%=
  18605. rec_no(k$,key%,P%)
  18606. 5>%  
  18607. readsmarray(dbasehandle%,REC%)
  18608.   examined%+=1
  18609. (Search$)=
  18610. 5A5    
  18611.  special%(7) 
  18612. (libfunc$+"_function(7)")
  18613.  action% 
  18614. 5C"      
  18615.  ### print/mark ###
  18616.       
  18617.  matchopt% 
  18618. 5E&        
  18619. print_record(REC%,P%)
  18620. 5FF        
  18621.  SHmarkptr%?REC%=0 
  18622.  SHmarkptr%?REC%=1:MarkedRecs%+=1
  18623. 5GG        
  18624.  SHmarkptr%?REC%=1 
  18625.  SHmarkptr%?REC%=0:MarkedRecs%-=1
  18626.       
  18627.       printed%+=1
  18628. 5J/      
  18629.  2:ptr%?REC%=file%:
  18630.  ### earmark ###
  18631. 5K3      
  18632. write_csv_rec(REC%,Form$,csvhandle%)
  18633.       
  18634. 5M       
  18635.  ### create index ###
  18636. 5N7      KEY$=
  18637. key2(newkey%,1):
  18638. insert(KEY$,newkey%,
  18639.       
  18640. 5P!      
  18641.  ### global change ###
  18642.       S$=F$(Menufield%)
  18643.       
  18644. 5SC        
  18645. New$,$ws%)>0:S$=
  18646. wildcard_replace(S$,Old$,New$,$ws%)
  18647. 5TC        
  18648. New$,$wc%)>0:S$=
  18649. wildcard_replace(S$,Old$,New$,$wc%)
  18650.         
  18651.  numeric%:
  18652.         X%=0:Y%=0
  18653.         
  18654.  X%+=1
  18655. 5X)        
  18656. (S$) 
  18657. S$,X%,1))>0
  18658.         
  18659.  X%<=
  18660. (S$) 
  18661.           Y%=X%
  18662.           
  18663.  Y%+=1
  18664. 5\+          
  18665. (S$) 
  18666. S$,Y%,1))=0
  18667.         
  18668. 5^9        S$=
  18669. S$,X%-1)+
  18670. S$,X%,Y%-X%)+New$))+
  18671. S$,Y%)
  18672. 5_*        
  18673.  Old$<>"":
  18674.  S$=Old$ 
  18675.  S$=New$
  18676.         
  18677. :S$=New$
  18678.       
  18679. 5b)      
  18680. (S$)>TextLength% 
  18681.  flag% 
  18682. 5c:        
  18683. softerror(S$+","+Tag$(Menufield%),10):flag%=
  18684.         
  18685.  "Hourglass_On"
  18686.       
  18687. 5f)      F$(Menufield%)=
  18688. S$,TextLength%)
  18689. 5g*      
  18690. writesmarray(dbasehandle%,REC%)
  18691.       
  18692. 5i:      
  18693.  ### update time-dependent calcs on opening ###
  18694.       
  18695.  I%=1 
  18696.  fields%
  18697.         
  18698.  chartype%(I%) 
  18699. 5l.          
  18700.  21,27,28,32,34,40,45,59,80,81:
  18701. 5mR          
  18702.  $Rf%(I%) holds key legend or other important data. Don't overwrite
  18703.           
  18704. :$Rf%(I%)=F$(I%)
  18705. 5oI          
  18706.  updatethese% 
  18707. set_now(chartype%(I%),I%):F$(I%)=$Rf%(I%)
  18708.         
  18709.       
  18710. 5r6      
  18711.  update$(0)<>"" 
  18712.  changed%=
  18713. update_calcs(0)
  18714. 5s*      
  18715. writesmarray(dbasehandle%,REC%)
  18716.       
  18717. 5u/      
  18718.  ### assign new sequence numbers ###
  18719.       F$(F%)=sequenceval$
  18720. 5w+      sequenceval$=
  18721. (sequenceval$)+1)
  18722. 5x*      
  18723. writesmarray(dbasehandle%,REC%)
  18724. 5y/      $(SHkeyptr%(key%)+P%+8)=
  18725. key2(key%,1)
  18726. 5z        
  18727. 5|#  P%=
  18728. neighbour(key%,P%,direc%)
  18729. 5};  
  18730.  "Hourglass_Percentage",(examined%*100) 
  18731.  subtotal%
  18732.   multitask% 
  18733. poll(
  18734. wildcard_replace(S$,Old$,New$,type$)
  18735.  old$,new$,old2$,new2$,c$,L%,P%,R%
  18736.  type$ 
  18737.  $ws%:
  18738. D    
  18739. Old$,1)=$ws% 
  18740. New$,1)=$ws% 
  18741. Old$)=$ws% 
  18742. New$)=$ws%:
  18743. '    old$=
  18744. Old$,2)):new$=
  18745. New$,2))
  18746.     P%=
  18747. S$,old$)
  18748. 2    
  18749.  P%>0 
  18750. S$,P%-1)+new$+
  18751. S$,P%+
  18752. (old$))
  18753. (    
  18754. Old$,1)=$ws% 
  18755. New$,1)=$ws%:
  18756. /    old$=
  18757. Old$,2):new$=
  18758. New$,2)::R%=
  18759. (old$)
  18760. .    
  18761. S$,R%)=old$ 
  18762. (S$)-R%)+new$
  18763. $    
  18764. Old$)=$ws% 
  18765. New$)=$ws%:
  18766. *    old$=
  18767. Old$):new$=
  18768. New$):L%=
  18769. (old$)
  18770. *    
  18771. S$,L%)=old$ 
  18772.  S$=new$+
  18773. S$,L%+1)
  18774. (    
  18775. Old$,$ws%)>0 
  18776. New$,$ws%)>0:
  18777. P    P%=
  18778. Old$,$ws%):old$=
  18779. Old$,P%-1):L%=
  18780. (old$):old2$=
  18781. Old$,P%+1):R%=
  18782. (old2$)
  18783. 9    P%=
  18784. New$,$ws%):new$=
  18785. New$,P%-1):new2$=
  18786. New$,P%+1)
  18787. *    
  18788. S$,L%)=old$ 
  18789.  S$=new$+
  18790. S$,L%+1)
  18791. 0    
  18792. S$,R%)=old2$ 
  18793. (S$)-R%)+new2$
  18794.  $wc%:
  18795. (Old$)=
  18796. (New$) 
  18797.  P%=1 
  18798. (Old$)
  18799.       c$=
  18800. Old$,P%,1)
  18801. ;      
  18802.  c$<>$wc% 
  18803. S$,P%,1) 
  18804. S$,P%,1)=
  18805. New$,P%,1)
  18806. search(S$,key%,M%)
  18807.  P%,found%,info$,keybase%,rec%,cond$
  18808. keybase%=SHkeyptr%(key%)
  18809. Z%=0:P%=top:ident%=
  18810.   L%=P%
  18811.   P%=!(keybase%+L%+Z%)
  18812.  P%>0 
  18813.     info$=$(keybase%+P%+8)
  18814.      rec%=
  18815. rec_no(k$,key%,P%)
  18816.  P%=-L%:found%=
  18817. (val$+"(S$)="+val$+"LEFT$(info$,kl%)") 
  18818.       
  18819.  0:ident%=(key%=0)
  18820.       
  18821.  1:found%=
  18822. $      
  18823.  rec%=REC% 
  18824.  found%=
  18825.         
  18826.  found% 
  18827.  Z%=-
  18828. (val$+"(S$)>="+val$+"(info$)")*4
  18829.  found%
  18830. /=P%                                        
  18831.  ### M%=0 - Find leaf position at which to insert ###
  18832.  ### M%=1 - Find first match in tree (if there is one) ###
  18833.  ### M%=2 - Find exact matching record, checking for record no. ###
  18834. insert(
  18835.  S$,key%,dupwarn%)
  18836.  P%,avail%,kl%,keybase%,abort%
  18837.  Index$(key%)="" 
  18838.  Index deleted
  18839.  S$="" 
  18840.  null%(key%)=
  18841. keybase%=SHkeyptr%(key%)
  18842. "kl%=KL%(key%):val$=
  18843. type(key%)
  18844. search(S$,key%,0)
  18845.  ident% 
  18846. !    
  18847. selected(passW%,15):
  18848. "    
  18849. softerror(S$,37):abort%=
  18850.  dupwarn% 
  18851. 4      
  18852. confirm(
  18853. msg("Err45,"+S$)) 
  18854.  abort%=
  18855.       
  18856.  duplicates%+=1
  18857.  abort% 
  18858.  S$="*Failed*":
  18859. nextfree%=!keybase%
  18860.  !(keybase%+nextfree%)<=0 
  18861.   incr%=
  18862. ($Increment%)
  18863.  incr%>0 
  18864. #    
  18865. change_length(RA%+incr%,
  18866.  S$="*Failed*"
  18867.  S$="*Failed*" 
  18868. softerror("",2):
  18869.  avail%=!(keybase%+nextfree%)
  18870. .!(keybase%+nextfree%+Z%)=!(keybase%+P%+Z%)
  18871. $!(keybase%+nextfree%+(4-Z%))=-P%
  18872. $(keybase%+nextfree%+8)=S$
  18873. ,!(keybase%+nextfree%+8+KL%(key%)+1)=REC%
  18874. !(keybase%+P%+Z%)=nextfree%
  18875. !keybase%=avail%
  18876.  key%=0 
  18877.  RU%+=1
  18878. delete(
  18879.  S$,key%)
  18880.  P%,A%,kl%,keybase%
  18881.  Index$(key%)="" 
  18882.  Index deleted
  18883.  S$="" 
  18884.  null%(key%)=
  18885. keybase%=SHkeyptr%(key%)
  18886. A%=!keybase%
  18887. "kl%=KL%(key%):val$=
  18888. type(key%)
  18889. search(S$,key%,2)
  18890.  P%<0 
  18891. softerror(S$+","+Index$(key%),1):S$="*Failed*":
  18892. neighbour(key%,P%,0)
  18893. neighbour(key%,P%,1)
  18894. '!(keybase%+L%+Z%)=!(keybase%+P%+Z%)
  18895.     Q%=P%
  18896. ZL%=4-Z%
  18897. P1%=!(keybase%+P%+ZL%)
  18898.  P1%>0 
  18899.   info$=$(keybase%+P1%+8)
  18900.   P%=-
  18901. search(info$,key%,0)
  18902.   !(keybase%+P%+Z%)=P1%
  18903.  !(keybase%+PR%+4)<=0 
  18904.  !(keybase%+PR%+4)=-SU%
  18905.  !(keybase%+SU%+0)<=0 
  18906.  !(keybase%+SU%+0)=-PR%
  18907. !(keybase%+Q%)=A%
  18908. !keybase%=Q%
  18909.  key%=0 
  18910.  RU%-=1
  18911. save_keys
  18912.  keyN%
  18913.  present%<>7 
  18914.  "Hourglass_On"
  18915. refresh_dates
  18916. 3keybase%=SHkeyptr%(0):keybase%!4=
  18917. ($Increment%)
  18918.  SHkeyptr%(keyN%)>0
  18919.   keybase%=SHkeyptr%(keyN%)
  18920. 8  filelength%=
  18921. sliding_block_size(keyanchor%(keyN%))
  18922.  keyN%=0 
  18923.     index$=""
  18924.  index$="indexes."
  18925.  Index$(keyN%)<>"" 
  18926.  "OS_File",10,$database%+"."+index$+Index$(keyN%),&7F0,,keybase%,keybase%+filelength%
  18927.   keyN%+=1
  18928.  "Hourglass_Percentage",keyN%*100 
  18929.  (Keys%+1)
  18930.  "Hourglass_Off"
  18931. readsmarray(filehandle%,REC%)
  18932.  loop%
  18933.  "OS_Byte",229,1:
  18934.  "OS_Byte",124
  18935. #filehandle%=REC%*Length%
  18936. F$()=""
  18937.  loop%=1 
  18938.  fields%
  18939.  zerolen%?loop%=0 
  18940.  F$(loop%)=
  18941. #filehandle%
  18942.  loop%
  18943.  "OS_Byte",229,0
  18944.  special%(2) 
  18945. (libfunc$+"_function(2)")
  18946. writesmarray(F,
  18947.  loop%,F$,L%
  18948. #F=R%*Length%
  18949.  loop%=1 
  18950.  fields%
  18951. 6!!  F$=F$(loop%):L%=len%(loop%)
  18952.  zerolen%?loop%=0 
  18953. 6#+    
  18954. (F$)<=L% 
  18955. #F,F$ 
  18956. L%,"!")
  18957.  loop%
  18958. 6&    R%+=1
  18959.  special%(4) 
  18960. (libfunc$+"_function(4)")
  18961. check_save(T%)
  18962.  T%=0 
  18963. SaveCount%+=1
  18964.  SaveCount%*ReturnEvery%<T%*6000 
  18965.  buttonfield%(0,19)>0 
  18966.  wi%=mainW%:ic%=field%(buttonfield%(0,19)) 
  18967.  wi%=keypadW%:ic%=19
  18968.  autosave% 
  18969.   delay%=
  18970.  loop%=0 
  18971. invert(wi%,ic%)
  18972.     delay%+=50
  18973. >delay%
  18974.  1,-10,100,10
  18975. invert(wi%,ic%)
  18976.     delay%+=50
  18977. >delay%
  18978.  loop%
  18979.  undo%=2 
  18980. 6=$    
  18981. confirm(
  18982. msg("Err166")) 
  18983.       
  18984. invert(wi%,ic%)
  18985.       
  18986. mouse(0,0,4,wi%,ic%)
  18987.       
  18988. invert(wi%,ic%)
  18989.       undo%=0
  18990. 6B        
  18991. 6C      
  18992. SaveCount%=0
  18993.  Calculations ---------------------------------------------------------
  18994. calc_link(T$,type%)
  18995.  ### Sets up calculation formula window & menu entry ###
  18996. $CalcFunc%=T$
  18997.  I%=1 
  18998.   T$=
  18999. $CalcTitle%=T$
  19000. split_link(Fieldnumber%,real$,visible$)
  19001.  type% 
  19002.  6,7:
  19003. 6T0  $CalcForm%=Tag$(Fieldnumber%)+"="+visible$
  19004. 6U+  
  19005. shade(calcW%,2,
  19006. shade(calcW%,4,
  19007.   $CalcForm%=visible$
  19008. 6X+  
  19009. shade(calcW%,2,
  19010. shade(calcW%,4,
  19011. deselect(calcW%,2)
  19012. redraw_icon(calcW%,0)
  19013. OldField%=Fieldnumber%
  19014. set_up_calc(wi%,calc%)
  19015.  Ecalc%=10 
  19016.  moan_err%,
  19017. msg("Err211")
  19018. text(wi%,0)=ephemera$(calc%,0):
  19019. redraw_icon(wi%,0)
  19020. text(wi%,1)=ephemera$(calc%,2):
  19021. redraw_icon(wi%,1)
  19022. text(wi%,11)=
  19023. (calc%):
  19024. redraw_icon(wi%,11)
  19025. deselect(wi%,
  19026. selected_esg(wi%,1))
  19027.  calc%=Ecalc% 
  19028. text(wi%,14)="15"
  19029. text(wi%,6)="Include"
  19030. select(wi%,2)
  19031. 6j'  $
  19032. text(wi%,14)=ephemera$(calc%,3)
  19033. text(wi%,6)="Modify"
  19034. 6l,  
  19035. select(wi%,
  19036. (ephemera$(calc%,4))-252)
  19037. redraw_icon(wi%,14)
  19038. redraw_icon(wi%,6)
  19039. set_caret(0,wi%,0)
  19040. extra_calcs(wi%,ic%,b%)
  19041.  z%,I%,V%,F%,vis$,real$,F$,sp$
  19042. b%=b% 
  19043.  (%111)
  19044.  b%=4 
  19045.  z%=1 
  19046.  z%=-1
  19047.  ic% 
  19048. 6x.  
  19049.  15,16:
  19050.  ic%=15 
  19051.  calc%+=z% 
  19052.  calc%-=z%
  19053.  calc%>Ecalc% 
  19054.  calc%=0
  19055.  calc%<0 
  19056.  calc%=Ecalc%
  19057. set_up_calc(wi%,calc%)
  19058.  2,3:
  19059. 6}E  
  19060. selected(wi%,2) 
  19061. text(wi%,14)="15" 
  19062. text(wi%,14)="255"
  19063. redraw_icon(wi%,14)
  19064.  b%=2 
  19065.  b%=4 
  19066. &    fieldsM%=
  19067. field_menu(items%,1)
  19068. +    
  19069. show_pop_up_menu(fieldsM%,wi%,ic%)
  19070.   fieldfunc$="calc"
  19071. close_window(wi%):
  19072. restore_caret(returnto%)
  19073. clear_selection:
  19074. set_up_calc(wi%,Ecalc%)
  19075.   F%=MaxFields%+3+calc%
  19076. selected(wi%,2) 
  19077.  V%=254 
  19078.  V%=255
  19079.    len%(F%)=
  19080. text(wi%,14))
  19081.   vis$=$
  19082. text(wi%,0)
  19083.  vis$="" 
  19084.  moan_err%,
  19085. msg("Err212")
  19086. $  real$=
  19087. real_calc(vis$,V%,"F$")
  19088.  V%=254 
  19089.  real$="STR$("+real$+")"
  19090.   chartype%(F%)=V%
  19091. :  Tag$(F%)=$
  19092. text(wi%,1):
  19093.  Tag$(F%)="" 
  19094.  Tag$(F%)=vis$
  19095. calc_error(F$,F%,vis$,real$):
  19096. 1  F$()="107":
  19097.  Avoid 'division by zero' error
  19098. :  F$=
  19099. (real$):
  19100.  Test to see if formula contains errors
  19101.   F$()=""
  19102. 6  ephemera$(calc%,0)=vis$:ephemera$(calc%,1)=real$
  19103. @  ephemera$(calc%,2)=Tag$(F%):ephemera$(calc%,3)=
  19104. (len%(F%))
  19105.   ephemera$(calc%,4)=
  19106.  calc%=Ecalc% 
  19107. 3    
  19108. (-1) 
  19109.  F$="Y"+
  19110. (calc%) 
  19111.  F$="X"+
  19112. (calc%)
  19113. B    
  19114.  Determines whether output is concatenated (Y) or not (X)
  19115.     printorder$+=F$
  19116.     Ecalc%+=1
  19117. 0    
  19118.  1:calc%=Ecalc%:
  19119. set_up_calc(wi%,calc%)
  19120. =    
  19121. close_window(wi%):
  19122. set_caret(0,mainW%,returnto%)
  19123. shade(matchW%,7,printorder$<>"")
  19124.  I%=7 
  19125. lit(printM%,I%,printorder$<>"")
  19126. calc_formula(F%,wi%,ic%,b%,S$)
  19127.  ### Parses calculation formula (S$) & builds calc$(F%) ###
  19128.  C$,F$,N%
  19129. b%=b% 
  19130.  (%111)
  19131.  S$="" 
  19132.  calc$(F%)=""
  19133.  ic% 
  19134. close_window(wi%):
  19135. restore_caret(returnto%)
  19136.  b%=2 
  19137.  b%=4 
  19138. &    fieldsM%=
  19139. field_menu(items%,1)
  19140. +    
  19141. show_pop_up_menu(fieldsM%,wi%,ic%)
  19142.   fieldfunc$="calc"
  19143. #  C$=
  19144. ~(F%):
  19145.  F%<16 
  19146.  C$="0"+C$
  19147.  $CalcFunc%="Set base value..." 
  19148. split_link(F%,R$,V$)
  19149. (S$)>=
  19150. (R$) 
  19151.       
  19152.  S$="" 
  19153.  S$="0"
  19154.       calc$(F%)=S$+"|"+S$
  19155.       calc$(0)="LOADED"
  19156.       
  19157. display(key%,-1)
  19158.       
  19159. softerror(R$,209)
  19160.         
  19161.         
  19162. &    P%=
  19163. S$,"="):visible$=
  19164. S$,P%+1)
  19165. 4    S$=
  19166. real_calc(visible$,chartype%(F%),"$Rf%")
  19167. 2    
  19168. calc_error(F$,F%,visible$,S$):
  19169.  S$<>"" 
  19170. 1      
  19171.  chartype%(F%)=6 
  19172. (S$) 
  19173.         
  19174. #    
  19175. (S$)+
  19176. (visible$)+2<256 
  19177. '      calc$(F%)="#"+S$+"#"+visible$
  19178.       calc$(0)="LOADED"
  19179. /      
  19180. selected(wi%,2) 
  19181. recalculate(F%)
  19182.       
  19183. softerror("",44)
  19184.         
  19185.   F%=0:
  19186. deselect(wi%,2)
  19187. asterisk(
  19188.  b%=4 
  19189. close_window(wi%)
  19190. real_calc(S$,V%,ar$)
  19191.  I%,P%,L%,t$,s$,f$,ok$,cl$,cr$,time%,date%,user%,ok%
  19192. ar$+="("
  19193. ok$="(),.+-*/=<> "
  19194.  I%=fields% 
  19195.  vtype$(chartype%(I%))<>"O" 
  19196. !    t$=Tag$(I%):L%=
  19197. (t$):P%=0
  19198.  t$<>"" 
  19199.       f$=ar$+
  19200. (I%)+")"
  19201.       
  19202. %        user%=(
  19203. S$,"FNU",P%+1)>0)
  19204. )        P%=
  19205. S$,t$,P%+1):cl$="":cr$=""
  19206.         
  19207.  P%>0 
  19208. .          cl$=
  19209. S$,P%-1,1):cr$=
  19210. S$,P%+L%,1)
  19211.           
  19212. C            
  19213.  Check that located tag isn't substring of another
  19214.             
  19215.  S$=t$:ok%=
  19216. 0            
  19217. S$,L%)=t$ 
  19218. ok$,cr$)>0:ok%=
  19219. 0            
  19220. S$,L%)=t$ 
  19221. ok$,cl$)>0:ok%=
  19222. 1            
  19223. ok$,cl$)>0 
  19224. ok$,cr$)>0:ok%=
  19225.             
  19226. :ok%=
  19227.           
  19228. )          
  19229.  ok% 
  19230.  chartype%(I%)<>33 
  19231.             s$=f$
  19232. "            
  19233.  chartype%(I%) 
  19234. 6              
  19235.  3,6,46,47,54,56,57,74,75,77,78,79:
  19236. A              
  19237.  user% 
  19238.  s$="VAL("+f$+")":
  19239.  Treat as numbers
  19240. I              
  19241.  5,50,51,70,71:
  19242.  user% 
  19243.  s$="FNdays("+f$+")":date%=
  19244. F              
  19245.  8,48,68:
  19246.  user% 
  19247.  s$="FNseconds("+f$+")":time%=
  19248.               
  19249.               
  19250. v                
  19251.  user% 
  19252.  s$="FNn("+
  19253. (I%)+")":
  19254.  If not in user func. assume no. from next col. of val. table
  19255.               
  19256.             
  19257. *            S$=
  19258. S$,P%-1)+s$+
  19259. S$,P%+L%)
  19260. /            
  19261.  ar$="$Rf%(" 
  19262.  update$(I%)+=C$
  19263.           
  19264.         
  19265.       
  19266.  P%=0
  19267.         
  19268. S$,"TIME$")>0 
  19269.  ar$="$Rf%(" 
  19270.  update$(0)+=C$
  19271.  time%=
  19272.  V%=7 
  19273.  S$="FNtime("+S$+")"
  19274.  date%=
  19275.  V%=7 
  19276.  S$="FNdate("+S$+","+
  19277. (len%(F%))+")"
  19278. recalculate(F%)
  19279.  F,I%,R%,k$,P%,real$,visible$,subtotal%,zero%,examined%
  19280. calc_error(F$,F%,visible$,real$):
  19281. split_link(F%,real$,visible$)
  19282. 'visible$=
  19283. replace(visible$,",","\")
  19284. confirm(
  19285. msg("Err206,"+Tag$(F%)+","+visible$))=
  19286. %subtotal%=
  19287. count_recs(key%,zero%)
  19288.  "Hourglass_On"
  19289. *dbasehandle%=
  19290. ($database%+".Database")
  19291. neighbour(key%,top,1)
  19292.  P%<>top
  19293.   R%=
  19294. rec_no(k$,key%,P%)
  19295. readsmarray(dbasehandle%,R%)
  19296.  I%=1 
  19297.  fields%
  19298. -    
  19299.  chartype%(I%)<>40 
  19300.  $Rf%(I%)=F$(I%)
  19301.  chartype%(F%) 
  19302.     F=
  19303. (real$):F$=
  19304. +    
  19305.  fix%(F%)>0 
  19306. fix_point(F$,F%)
  19307.  7:F$=
  19308. (real$)
  19309. (F$)<=len%(F%) 
  19310.  F$(F%)=F$
  19311. 7 $  
  19312. writesmarray(dbasehandle%,R%)
  19313.   P%=
  19314. neighbour(key%,P%,1)
  19315.   examined%+=1
  19316. 7#9  
  19317.  "Hourglass_Percentage",examined%*100 
  19318.  subtotal%
  19319.  "Hourglass_Off"
  19320. close_file(dbasehandle%)
  19321.  I%=1 
  19322.  fields%
  19323.  chartype%(I%) 
  19324. 7)"    
  19325.  21,27,28,32,34,40,45,59:
  19326. 7*M    
  19327.  $Rf%(I%) holds key legend or other important data. Don't overwrite!
  19328. :$Rf%(I%)=field$(I%)
  19329. 7,      
  19330. display(key%,addr)
  19331. asterisk(
  19332. save_calcs
  19333.  calc$(0)="LOADED" 
  19334. ($database%+".Calc")
  19335.  F%=1 
  19336.  fields%
  19337. #F,calc$(F%)
  19338. close_file(F)
  19339. sums(
  19340.  F$,F%,type%)
  19341.  F$<>"" 
  19342.  type% 
  19343.  8:V=
  19344. seconds(F$)
  19345.   Sum(F%,0)+=1
  19346.   Sum(F%,1)+=V
  19347.   Sum(F%,3)+=V*V
  19348. 7H!  
  19349.  V>Sum(F%,4) 
  19350.  Sum(F%,4)=V
  19351. 7I!  
  19352.  V<Sum(F%,5) 
  19353.  Sum(F%,5)=V
  19354. ctotals(flag%)
  19355.  F%,I%,J%,N%,R%,S%,pos%,F$,last%,sp$,N
  19356. last%=
  19357. (Form$)-1
  19358.  I%=1 
  19359.  last% 
  19360.   F%=
  19361. fnum(
  19362. Form$,I%,2))
  19363.   R%=calcrow%?F%
  19364.  chartype%(F%) 
  19365. 7T.    
  19366.  3,6,8,46,47,54,56,57,74,75,77,78,79:
  19367.  Sum(R%,0)>0 
  19368. 7V'      Sum(R%,2)=Sum(R%,1)/Sum(R%,0)
  19369. 7W+      N=Sum(R%,3)/Sum(R%,0)-Sum(R%,2)^2
  19370. 7X.      
  19371.  N>0 
  19372.  Sum(R%,3)=
  19373.  Sum(R%,3)=0
  19374. 7Y        
  19375. 7Z'    
  19376.  Sum(R%,5)=10^30 
  19377.  Sum(R%,5)=0
  19378.  J%=0 
  19379. 7^F  
  19380.  flag%=TRUE means that first field in list is involved in calcs
  19381.  flag% 
  19382. 7`<    N%=0:start%=1:F$=
  19383. justify(S$(J%),1,0," ")+" ":pos%=0
  19384. 7a/    
  19385.  N%=1:start%=3:F$=S$(J%):pos%=Lmargin%
  19386. store_string(F$,pos%,
  19387. (Form$)>2 
  19388.  start%=1 
  19389.  I%=start% 
  19390.  last% 
  19391. 7f+      
  19392.  I%<last% 
  19393.  sp$=spacer$ 
  19394.  sp$=""
  19395. 7g&      F%=
  19396. fnum(
  19397. Form$,I%,2)):F$=""
  19398.       N%+=1
  19399.       
  19400.  chartype%(F%) 
  19401. 7j2        
  19402.  3,6,8,46,47,54,56,57,74,75,77,78,79:
  19403.         R%=calcrow%?F%
  19404. 7lQ        
  19405.  chartype%(F%)=8 
  19406.  result$=
  19407. time(Sum(R%,J%)) 
  19408.  result$=
  19409. (Sum(R%,J%))
  19410. 7mZ        
  19411. selected(numscrollW%,R%*8-6+J%) 
  19412. justify(result$,N%+1,N%,sp$):f%(J%)=1
  19413.       
  19414. 7o&      
  19415. store_string(F$,Tab%(N%),
  19416.  f%(J%)=1 
  19417.       
  19418. store_rec_num(-1)
  19419.       
  19420. end_line
  19421. 7t        
  19422. (f%())>0 
  19423.  format$="horiz" 
  19424.  $TextPtr%=
  19425. 8," "):
  19426. margin_check
  19427.  f%,F%,R%,J%
  19428. fnum(
  19429. Form$,2))
  19430.  chartype%(F%) 
  19431. 7~*  
  19432.  3,6,46,47,54,56,57,74,75,77,78,79:
  19433.   R%=calcrow%?F%
  19434.  J%=0 
  19435. 2    
  19436. selected(numscrollW%,R%*8-6+J%) 
  19437.  f%=F%
  19438.  f%>0 
  19439.  Lmargin%=8:Tab%(0)=0:Tab%(1)=Lmargin%:=
  19440. justify(f$,x%,x1%,s$)
  19441. L%=Tab%(x%)-Tab%(x1%)-
  19442. (f$)>L% 
  19443.   f$=
  19444. f$,L%)
  19445. (f$)," ")+f$
  19446. f$)="." 
  19447.  f$=" "+
  19448. execute_file(F%)
  19449.  S$,file$,d%,F
  19450. link$(F%),1)="@" 
  19451.   file$=
  19452. link$(F%),2)
  19453. *  file$=
  19454. filename(file$,"PrintRes",-1)
  19455.  "OS_File",5,file$ 
  19456.  d%,,type%
  19457.   type%=(type%>>8) 
  19458.  &fff
  19459.  type%=&fff 
  19460. (file$):S$=
  19461. close_file(F)
  19462. ;    
  19463. S$,7)="!SCRIPT" 
  19464. (-1):
  19465. execute_script(file$)
  19466. (    
  19467.  "OS_CLI","Filer_Run "+file$
  19468. execute_script(f$)
  19469.  F,P%,F%,F$,junk$,line$,name$,params$,command$,file$,from$,to$,oscli$,space%,finished%,firstquery%,state%,X%,spr$,z%,input%,cancel%,f%
  19470. selected(printW%,23) 
  19471.  reportdest$="File" 
  19472.  reportdest$="Window"
  19473. abort_script:
  19474.  finished% 
  19475.  cancel%)
  19476.   line$=
  19477.   space%=
  19478. line$," ")
  19479.  space%=0 
  19480.  command$=line$:params$="" 
  19481.  command$=
  19482. line$,space%-1):params$=
  19483. line$,space%+1)
  19484.   P%=
  19485. params$,"\")
  19486.  P%>0 
  19487. 6    name$=
  19488. filename(
  19489. params$,P%-1),"PrintJobs",-1)
  19490.     params$=
  19491. params$,P%+1)
  19492.  name$=""
  19493. $  params$=
  19494. get_input(params$,f%)
  19495.  command$<>"!MESSAGE" 
  19496.  params$=
  19497. u(params$)
  19498.   state%=(params$="ON")
  19499.  command$ 
  19500. @    
  19501.  Do nothing - probably a blank line at end of file
  19502.  "!SCRIPT":
  19503.     ImpCom$=""
  19504.  params$ 
  19505. :      
  19506.  "QUIET":
  19507.  Do nothing. No confirmation required
  19508.       
  19509.  "","POWERBASE":
  19510. >      
  19511. confirm(
  19512. msg("Err68,"+
  19513. leaf(f$))) 
  19514.  finished%=
  19515.       
  19516.  "END":finished%=
  19517.       
  19518. 2      file$=
  19519. filename(params$,"PrintRes",&fff)
  19520. .      
  19521.  file$<>"" 
  19522. execute_script(file$)
  19523.         
  19524. !    
  19525.  "!COMMENT":
  19526.  Do nothing
  19527.  "!MESSAGE":
  19528.  params$<>"" 
  19529.       T%=
  19530. params$))
  19531. $      
  19532.  T%>0 
  19533.  params$=
  19534. params$)
  19535. $      
  19536. inform(
  19537. params$,80),0,T%)
  19538.       
  19539. close_it(informW%)
  19540.         
  19541.  "!SELECTION":
  19542.  params$<>"" 
  19543. 2      file$=
  19544. filename(params$,"PrintRes",&7f3)
  19545.       
  19546.  file$="" 
  19547. 3        
  19548. read_items_from_list(params$,"select")
  19549. $        
  19550. load_selection(file$)
  19551.       
  19552.       
  19553. clear_selection
  19554.         
  19555.  "!PRINTOPTS":
  19556.  params$<>"" 
  19557. 2      file$=
  19558. filename(params$,"PrintRes",&7f5)
  19559. =      
  19560.  file$<>"" 
  19561. get_options(printW%,printerW%,file$)
  19562.       
  19563. ?      
  19564.  "OS_File",5,$database%+".PrintRes.!PrintOpts" 
  19565.       
  19566.  d%=1 
  19567. M        
  19568. get_options(printW%,printerW%,$database%+".PrintRes.!PrintOpts")
  19569.         
  19570. N        
  19571. get_options(printW%,printerW%,"<Pbase$Dir>.Resources.!PrintOpts")
  19572.       
  19573.         
  19574.  "!SUBFILES":
  19575.  ic%=6 
  19576.        
  19577. deselect(queryW%,ic%)
  19578.     params$+=",":I%=0
  19579.         
  19580.       I%+=1
  19581.       P%=
  19582. params$,",")
  19583. 4      par$=
  19584. params$,P%-1):params$=
  19585. params$,P%+1)
  19586. $      
  19587. select(queryW%,
  19588. (par$)+6)
  19589.  params$=""
  19590. -    
  19591.  "!CASE":
  19592. set_icon(queryW%,1,state%)
  19593.  "!QUERY":
  19594. I    
  19595.  (format$="table" 
  19596.  format$="label") 
  19597. selected(printW%,25) 
  19598. >      
  19599.  moan_err%,
  19600. msg("Err208,"+format$+","+reportdest$) 
  19601.       
  19602.       
  19603.  params$<>"" 
  19604. 4        file$=
  19605. filename(params$,"PrintRes",&7f4)
  19606. I        
  19607.  file$<>"" 
  19608.  "OS_File",255,file$,Query% 
  19609.  $Query%=params$
  19610.         
  19611. default_query
  19612.       
  19613. 8      
  19614.  $Query%="" 
  19615.  displayed%=REC% 
  19616.  displayed%=-1
  19617.       Search$=
  19618. parse
  19619.       
  19620.  name$="" 
  19621. L        
  19622.  displayed%=-1 
  19623.  name$=
  19624. query$,NameLength%) 
  19625.  name$="Displayed"
  19626. 4        TextName$=$database%+".PrintJobs."+name$
  19627.         
  19628.  TextName$=name$
  19629.       
  19630.       
  19631.  reportdest$ 
  19632. +        
  19633.  "Window":$SaveName%=TextName$
  19634.         
  19635.  "File":
  19636. C        texthandle%=
  19637. (TextName$):
  19638.  "OS_File",18,TextName$,&fff
  19639.         
  19640.  ImpCom$<>"" 
  19641.           
  19642. -            
  19643.  firstquery%=
  19644. :firstquery%=
  19645. '            
  19646. #texthandle%,ImpCom$
  19647.           
  19648.         
  19649.       
  19650.         
  19651. "    
  19652. do_it(Search$,displayed%)
  19653. "    
  19654.  "!FILTER","!FILTEROPEN":
  19655.  params$<>"" 
  19656. 2      $Query%=params$:Filter$=
  19657. parse:filter%=
  19658.       
  19659. select(keypadW%,22)
  19660. 8    U      
  19661.  field%(buttonfield%(0,22))>0 
  19662. select(mainW%,field%(buttonfield%(0,22)))
  19663. "      addr=
  19664. moveto(key%,top,1)
  19665.       
  19666. *      filter%=
  19667. deselect(keypadW%,22)
  19668. W      
  19669.  field%(buttonfield%(0,22))>0 
  19670. deselect(mainW%,field%(buttonfield%(0,22)))
  19671.         
  19672. Y    
  19673.  command$="!FILTEROPEN" 
  19674. position_window(filterW%,0,0,0,0,0,0):$Query%=params$
  19675.  "!SAVE":
  19676. /    file$=
  19677. filename(params$,"PrintJobs",-1)
  19678. ?    
  19679. save(file$,&fff,SHtextptr%,SHtextptr%+Count%*LenLine%)
  19680.  "!CSV":
  19681.  params$<>"" 
  19682. 2      file$=
  19683. filename(params$,"PrintRes",&7f4)
  19684. G      
  19685.  file$<>"" 
  19686.  "OS_File",255,file$,Query% 
  19687.  $Query%=params$
  19688.       
  19689. default_query
  19690.         
  19691. :    
  19692.  name$="" 
  19693.  name$=$database%+".PrintJobs.CSVfile"
  19694. 6    
  19695.  $Query%="" 
  19696.  displayed%=REC% 
  19697.  displayed%=-1
  19698. $    
  19699. write_csv(name$,displayed%)
  19700.      
  19701.  "!INCLUDE","!EXCLUDE":
  19702. 0    file$=
  19703. filename(params$,"PrintRes",&fff)
  19704. _    
  19705.  file$="" 
  19706. read_items_from_list(params$,"mark") 
  19707. read_keys_from_file(file$,"mark")
  19708.  command$ 
  19709. 8 &      
  19710.  "!INCLUDE":z%=
  19711. :spr$="yes"
  19712. 8!%      
  19713.  "!EXCLUDE":z%=
  19714. :spr$="no"
  19715. 8"        
  19716. 8#/    
  19717. tick(markM%,0,z%):
  19718. tick(markM%,1,
  19719. 8$%    $
  19720. val(markW%,0)="Snull,"+spr$
  19721. warn_of_marks
  19722. 8&3    
  19723.  "!CLEAR":
  19724. clear_marks(RA%):
  19725. warn_of_marks
  19726.  "!FORMAT":
  19727. 8(3    
  19728. deselect(printW%,
  19729. selected_esg(printW%,3))
  19730. params$,1) 
  19731.       
  19732.  "V":format$="vert"
  19733.       
  19734.  "T":format$="table"
  19735.       
  19736.  "L":format$="label"
  19737.       
  19738. :format$="horiz"
  19739. 8.        
  19740. set_format(format$)
  19741.  "!DESTINATION":
  19742. 813    
  19743. deselect(printW%,
  19744. selected_esg(printW%,4))
  19745. params$,1) 
  19746. 83)      
  19747.  "F":ic%=23:reportdest$="File"
  19748. 84,      
  19749.  "P":ic%=25:reportdest$="Printer"
  19750. 85'      
  19751. :ic%=22:reportdest$="Window"
  19752. 86A      TextName$=$database%+".PrintJobs."+
  19753. query$,NameLength%)
  19754. 87        
  19755. select(printW%,ic%)
  19756. set_dest_sprite
  19757. 8:0    
  19758. shade(printW%,42,
  19759. selected(printW%,25))
  19760. 8;/    
  19761.  "!EXPAND":
  19762. set_icon(printW%,5,state%)
  19763. 8<.    
  19764.  "!DATE":
  19765. set_icon(printW%,11,state%)
  19766. 8=.    
  19767.  "!UPPER":
  19768. set_icon(printW%,6,state%)
  19769. 8>0    
  19770.  "!HEADER":
  19771. set_icon(printW%,28,state%)
  19772. 8?0    
  19773.  "!FOOTER":
  19774. set_icon(printW%,29,state%)
  19775. 8@.    
  19776.  "!FIRST":
  19777. set_icon(printW%,4,state%)
  19778. 8A0    
  19779.  "!SHRINK":
  19780. set_icon(printW%,24,state%)
  19781.  "!HEADINGS":
  19782. 8C3    
  19783. deselect(printW%,
  19784. selected_esg(printW%,1))
  19785.  params$ 
  19786.       
  19787.  "D":ic%=2
  19788.       
  19789.  "T":ic%=1
  19790.       
  19791. :ic%=36
  19792. 8H        
  19793. select(printW%,ic%)
  19794. 8J-    
  19795.  "!TITLE":$
  19796. text(printW%,10)=params$
  19797. 8K+    
  19798.  "!PAGE":$
  19799. text(printW%,9)=params$
  19800. 8L.    
  19801.  "!SPACER":$
  19802. text(printW%,26)=params$
  19803. 8M1    
  19804.  "!TEXTWIDTH":$
  19805. text(printW%,18)=params$
  19806.  "!ORIENTATION":
  19807. 8O7    
  19808. deselect(printerW%,
  19809. selected_esg(printerW%,1))
  19810.  params$ 
  19811. 8Q7      
  19812.  "SIDEWAYS","LANDSCAPE":
  19813. select(printerW%,4)
  19814. 8R       
  19815. select(printerW%,3)
  19816. 8S        
  19817.  "!PRINTCOLUMNS":
  19818. 8U7    
  19819. deselect(printerW%,
  19820. selected_esg(printerW%,9))
  19821.  params$ 
  19822. 8W%      
  19823.  "2":
  19824. select(printerW%,81)
  19825. 8X%      
  19826.  "3":
  19827. select(printerW%,85)
  19828. 8Y%      
  19829.  "4":
  19830. select(printerW%,86)
  19831. 8Z!      
  19832. select(printerW%,80)
  19833. 8\4    
  19834.  "!HEADERFONT":$
  19835. text(printerW%,57)=params$
  19836. 8]2    
  19837.  "!BODYFONT":$
  19838. text(printerW%,71)=params$
  19839.  "!FONTSIZE":
  19840. 8_7    
  19841. deselect(printerW%,
  19842. selected_esg(printerW%,7))
  19843. (params$) 
  19844. 8a#      
  19845. select(printerW%,61)
  19846. 8b$      
  19847. select(printerW%,62)
  19848. 8c$      
  19849. select(printerW%,63)
  19850. 8d$      
  19851. select(printerW%,64)
  19852. 8e(      
  19853. text(printerW%,65)=params$
  19854. 8f        
  19855. 8g6    
  19856.  "!LMARGIN","!RMARGIN","!TMARGIN","!BMARGIN":
  19857. deselect(printerW%,68)
  19858. 8i&    params$=
  19859. change_units(params$)
  19860.  command$ 
  19861.       
  19862.  "!LMARGIN":ic%=14
  19863.       
  19864.  "!RMARGIN":ic%=15
  19865.       
  19866.  "!TMARGIN":ic%=16
  19867.       
  19868.  "!BMARGIN":ic%=18
  19869. 8o        
  19870. 8p%    $
  19871. text(printerW%,ic%)=params$
  19872. 8q+    
  19873.  "!PMARGINS":
  19874. select(printerW%,68)
  19875. 8r3    
  19876.  "!LINESPACE":$
  19877. text(printerW%,56)=params$
  19878.  "!TABLE":
  19879.     params$+=","
  19880.  I%=1 
  19881.       P%=
  19882. params$,",")
  19883. 8w4      par$=
  19884. params$,P%-1):params$=
  19885. params$,P%+1)
  19886. 8x"      par$=
  19887. get_input(par$,f%)
  19888.       
  19889.  par$<>"" 
  19890.         
  19891. 8{+          
  19892. text(printerW%,23)=par$
  19893. 8|D          
  19894.  2:par$=
  19895. change_units(par$):$
  19896. text(printerW%,24)=par$
  19897. 8}+          
  19898. text(printerW%,69)=par$
  19899.         
  19900.       
  19901.  "!LABEL":
  19902.     params$+=",":I%=0
  19903.         
  19904.       I%+=1
  19905.       P%=
  19906. params$,",")
  19907. 4      par$=
  19908. params$,P%-1):params$=
  19909. params$,P%+1)
  19910. "      par$=
  19911. get_input(par$,f%)
  19912.       
  19913.  par$<>"" 
  19914.         
  19915.           
  19916. =          
  19917. deselect(printerW%,
  19918. selected_esg(printerW%,5))
  19919.           
  19920.  par$ 
  19921. +            
  19922.  "1":
  19923. select(printerW%,28)
  19924. +            
  19925.  "2":
  19926. select(printerW%,29)
  19927. +            
  19928.  "3":
  19929. select(printerW%,30)
  19930. '            
  19931. select(printerW%,53)
  19932.           
  19933. D          
  19934.  2:par$=
  19935. change_units(par$):$
  19936. text(printerW%,32)=par$
  19937. D          
  19938.  3:par$=
  19939. change_units(par$):$
  19940. text(printerW%,34)=par$
  19941. +          
  19942. text(printerW%,51)=par$
  19943. +          
  19944. text(printerW%,52)=par$
  19945. +          
  19946. text(printerW%,55)=par$
  19947. A          
  19948. text(printerW%,78)=par$:
  19949. select(printerW%,39)
  19950. +          
  19951. text(printerW%,40)=par$
  19952. 9          
  19953. set_icon(printerW%,41,(
  19954. u(par$)="ON"))
  19955.         
  19956.       
  19957.  params$=""
  19958. 0    
  19959.  "!COPIES":$
  19960. text(printerW%,45)=params$
  19961. P    
  19962.  "!SORT":$
  19963. text(printW%,44)=params$:
  19964. set_icon(printW%,46,(params$<>""))
  19965.  "!IMPRESSION":
  19966.     P%=
  19967. params$," ")
  19968.  P%>0 
  19969. =      ImpCom$=
  19970. params$,P%-1):modifier$=
  19971. params$,P%+1))
  19972.       
  19973.  modifier$ 
  19974. '        
  19975.  "NOT FIRST":firstquery%=
  19976.       
  19977.       
  19978.  ImpCom$=params$
  19979.             
  19980.  "!DELETE","!MOVE":
  19981. *    
  19982.  command$="!DELETE" 
  19983.  z%=0 
  19984.  z%=1
  19985.  present%=7 
  19986. 3      
  19987. select(searchW%,6):
  19988. deselect(searchW%,5)
  19989. 2      file$=
  19990. filename(params$,"PrintRes",&fff)
  19991. e      
  19992.  file$="" 
  19993. read_items_from_list(params$,"delete") 
  19994. read_keys_from_file(file$,"delete")
  19995. "      addr=
  19996. moveto(key%,top,1)
  19997.         
  19998.  "!INSERT":
  19999.  present%=7 
  20000. 0      subfile%=
  20001. (params$):top=8*subfile%+LH%
  20002.       
  20003. make_new_rec
  20004.       
  20005.  loop%=1 
  20006.  fields%
  20007. )        $Rf%(loop%)=
  20008. #F,len%(loop%))
  20009.       
  20010.       
  20011. write(fields%,key%)
  20012.       top=8*file%+LH%
  20013.       
  20014. asterisk(
  20015.         
  20016.  "!CHANGE":
  20017.  params$<>"" 
  20018.       P%=
  20019. params$,",")
  20020. 2      F$=
  20021. params$,P%-1):params$=
  20022. params$,P%+1)
  20023. *      F%=
  20024. field(X%,F$,
  20025. ):Menufield%=F%
  20026.       P%=
  20027. params$,",")
  20028. 5      from$=
  20029. params$,P%-1):params$=
  20030. params$,P%+1)
  20031.       P%=
  20032. params$,",")
  20033.       
  20034.  P%>0 
  20035. 5        to$=
  20036. params$,P%-1):$Query%=
  20037. params$,P%+1)
  20038.         
  20039.  to$=params$
  20040.       
  20041. '      
  20042. changes(key%,F%,from$,to$,
  20043.         
  20044.  "!OBEY":
  20045.     P%=
  20046. params$," ")
  20047. G    
  20048.  P%>0 
  20049.  oscli$=
  20050. params$,P%):params$=
  20051. params$,P%+1) 
  20052.  oscli$=""
  20053. 0    file$=
  20054. filename(params$,"PrintRes",&feb)
  20055. D    
  20056.  file$<>"" 
  20057.  "OS_CLI",oscli$+file$ 
  20058.  "OS_CLI",params$
  20059. "    
  20060.  "!KEY":
  20061. set_key(params$)
  20062.  "!INDEX":
  20063.  params$="" 
  20064. 2      
  20065. read_items_from_list(indexes$,"remove")
  20066. C      
  20067. read_items_from_list(params$,"index"):indexes$=params$
  20068.         
  20069.  "!STARTAT":
  20070.  params$="" 
  20071. ,      starthere%=field%(
  20072. first_writable)
  20073. 4      
  20074.  $StartHere%=params$:starthere%=
  20075. start_at
  20076.         
  20077. '    
  20078. set_caret(0,mainW%,starthere%)
  20079. softerror(command$,46)
  20080.     finished%=
  20081.  "Hourglass_Smash"
  20082. close_file(F)
  20083. close_it(informW%)
  20084. set_caret(0,mainW%,starthere%)
  20085. get_input(S$,
  20086.  flag%)
  20087. flag%=(
  20088. S$,"?")>0)
  20089. S$)<>"?" 
  20090. $Prompt%=S$:$Params%=""
  20091. position_window(inputW%,0,0,0,0,0,0)
  20092. set_caret(0,inputW%,1)
  20093. poll(
  20094.  input% 
  20095.  cancel% 
  20096.  quit%
  20097. close_it(inputW%)
  20098. set_caret(0,mainW%,starthere%)
  20099. input%=
  20100. :flag%=
  20101. =$Params%
  20102. change_units(params$)
  20103.  ic%,units$
  20104. units$=
  20105. params$,2)
  20106. deselect(printerW%,
  20107. selected_esg(printerW%,8))
  20108.  units$ 
  20109.  "MM":units$="mm":ic%=48
  20110.  "IN":units$="in":ic%=38
  20111.  "PT":units$="pt":ic%=77
  20112. :units$="mm":ic%=48
  20113. select(printerW%,ic%)
  20114. convert_units
  20115. params$=
  20116. (params$))
  20117. =params$
  20118. filename(name$,default$,type%)
  20119.  f$,s$,ftype%,d%,P%
  20120.  name$="":f$=name$
  20121. name$,"::")>0,
  20122. name$,"<"):f$=name$
  20123.  Full pathname (or one using system variable) stored. Leave it alone!  
  20124. 9    F  
  20125. name$,".")=0:f$=$database%+"."+default$+"."+name$:
  20126.  Leaf only
  20127. name$,1)="^":f$=$database%+"."+name$:
  20128.  Pathname relative to dbase
  20129.  "Beheaded" pathname. Glue correct head to body!
  20130. $  P%=
  20131. name$,"."):s$=
  20132. name$,P%-1)
  20133.   P%=
  20134. $database%,s$)
  20135.    f$=
  20136. $database%,P%-1)+name$
  20137.  type%=-1 
  20138.  "XOS_File",5,f$ 
  20139.  d%,,ftype%
  20140.  d%=0 
  20141. ftype%=(ftype%>>8) 
  20142.  &fff
  20143.  type%>0 
  20144.  type%<>ftype% 
  20145. read_keys_from_file(f$,action$)
  20146.  F,key$
  20147. close_file(F):
  20148. wimp_error(
  20149.   key$=
  20150.  action$ 
  20151. '    
  20152.  "delete":
  20153. delete_record(key$)
  20154. 9 #    
  20155.  "mark":
  20156. flag_record(key$)
  20157. close_file(F)
  20158. read_items_from_list(list$,action$)
  20159.  Fieldnumber%,P%,X%,L%,item$,sep$,F$
  20160. sep$=",":list$+=sep$
  20161.  action$="select" 
  20162.  printorder$=""
  20163.  list$<>""                                              
  20164.   P%=
  20165. list$,sep$)
  20166.   item$=
  20167. list$,P%-1)
  20168. 9.   item$=
  20169. get_input(item$,f%)
  20170.  item$<>"" 
  20171.     L%=0
  20172.  action$ 
  20173. 92*      
  20174.  "delete":
  20175. delete_record(item$)
  20176. 93&      
  20177.  "mark":
  20178. flag_record(item$)
  20179.       
  20180.  "select":
  20181.       
  20182.  item$ 
  20183. 960        
  20184.  "RECORD":
  20185. update_selection(
  20186. ,"00")
  20187. 97-        
  20188.  "KEY":
  20189. update_selection(
  20190. ,"KK")
  20191. 981        
  20192.  "SUBFILE":
  20193. update_selection(
  20194. ,"SF")
  20195.         
  20196. 9:+        Fieldnumber%=
  20197. field(X%,item$,
  20198. 9;#        
  20199. update_selection(
  20200.       
  20201.       
  20202.  "index":
  20203. 9>7      keyfield%()=0:keyfield%(0)=
  20204. field(X%,item$,
  20205.       L%=
  20206. (item$)
  20207.       
  20208.  L%>0 
  20209.         
  20210.           item$=
  20211. item$,2)
  20212.         
  20213. (item$)=0
  20214. 9D#        
  20215.  L%=len%(keyfield%(0))
  20216.       
  20217. 9FJ      $
  20218. text(keyW%,12)=item$:$
  20219. text(keyW%,13)="0":$
  20220. text(keyW%,14)="L"
  20221. 9G       $
  20222. text(keyW%,15)=
  20223.       
  20224. create_index(key%,
  20225.       
  20226. set_key(item$)
  20227. 9J+      
  20228.  "remove":
  20229. remove_index(item$,
  20230. 9K        
  20231. 9L      
  20232.   list$=
  20233. list$,P%+1)
  20234.  action$="select" 
  20235. select_them(
  20236. delete_record(key$)
  20237. RecF%=
  20238. addr=
  20239. find(key$,0,
  20240.  RecF% 
  20241.  addr=
  20242. shift(z%,0,0)
  20243. flag_record(key$)
  20244.  P%,REC%,k$
  20245. find(key$,0,
  20246.  P%>=0 
  20247.   REC%=
  20248. rec_no(k$,key%,P%)
  20249. 9]&  SHmarkptr%?REC%=1:MarkedRecs%+=1
  20250. abort_script
  20251. close_file(F)
  20252. format$="":reportdest$=""
  20253. softerror("",57)
  20254. wimp_error(
  20255.  "Impulse" handling -----------------------------------------------
  20256. Impulse_command_received(token%,params%,object%)
  20257. 9nDSHImpulseptr%=
  20258. extend_named_sliding_block(transanchor%,SHclaim%)
  20259. 9o4param$=
  20260. getstr(params%):object$=
  20261. getstr(object%)
  20262.  object$="" 
  20263.  object$=
  20264. leaf($database%)
  20265.  token% 
  20266. 9r@  
  20267.  ### GetPathname. Returns full pathname of object ###
  20268. leaf($database%) 
  20269.  object$:
  20270. 9u<    
  20271.  "Impulse_SendMessage",&202,$database%,,,,,mytask%
  20272.  "No data":
  20273. 9wD    
  20274.  "Impulse_SendMessage",&202,"No database open",,,,,mytask%
  20275. 9yT    
  20276.  "Impulse_SendMessage",&202,"Current database is not "+object$,,,,,mytask%
  20277. 9{:  
  20278.  ### Selection. Returns maximum data length ###
  20279.   ClientSep$=
  20280. param$,1)
  20281. 9}@  ClientForm$=
  20282. find_fields(param$,ClientSep$,ClientLengths$)
  20283. 9~>  
  20284.  "Impulse_SendMessage",&202,ClientLengths$,,,,,mytask%
  20285.  ### ParseQuery. Returns title generated by FNparse ###
  20286. )  $Query%=param$:ClientSearch$=
  20287. parse
  20288.  "Impulse_SendMessage",&202,Title$,,,,,mytask%
  20289.  ### GetRecord. Returns data specified in Selection according to criteria specified in ParseQuery ###
  20290. <  datalength%=
  20291. prepare_next_record(param$,SHImpulseptr%)
  20292.  "Impulse_SendMessage",&202,"Ready to receive?",-1,,,transtag%,mytask%,Length%
  20293.  ### PutRecord ###
  20294.  "Impulse_SendMessage",&201,"GetRecord",,,,getrec%,my         task%
  20295.  ### ExpandCode ###
  20296.   P%=
  20297. param$," ")
  20298. .  code$=
  20299. param$,P%-1):table$=
  20300. param$,P%+1)
  20301.  "Impulse_SendMessage",&202,
  20302. expand(code$,table$,L%,SF$,C%),,,,,mytask%
  20303.  7,8:
  20304.  ### GetField, GetExpanded ###
  20305.  params%<>-1 
  20306. 6    datalength%=
  20307. prepare_next_field(token%,param$)
  20308. \    
  20309.  "Impulse_SendMessage",&202,"Ready to receive?",-1,,,transtag%,mytask%,datalength%
  20310. :    
  20311.  ### Max. length for a Powerbase field is 246 ###
  20312.  ### NextMatch ###
  20313.  finished% 
  20314. #    
  20315. move_on_and_continue(key%)
  20316.         
  20317. M    $
  20318. text(mergeW%,6)="Merging complete. Final page will appear shortly."
  20319. redraw_icon(mergeW%,6)
  20320. move_on_and_continue(key%)
  20321.  S$,J%,F%,F1%
  20322. 7addr=
  20323. next_match(addr,direction%,Filter$,finished%)
  20324.  finished% 
  20325.  F$()="":
  20326.  J%=0 
  20327. 8  F1%=KF%(key%,J%):
  20328.  F1%<>F% 
  20329.  F%=F1%:S$+=F$(F%)+" "
  20330. text(mergeW%,6)=
  20331. S$,80):
  20332. redraw_icon(mergeW%,6)
  20333. Impulse_reply(replytag%,reply%)
  20334. abort_merge:
  20335. DSHImpulseptr%=
  20336. extend_named_sliding_block(transanchor%,SHclaim%)
  20337. reply$=
  20338. getstr(reply%)
  20339.  replytag% 
  20340.  getrec%:
  20341.  ### Reply to GetRecord command. ###
  20342.  "Impulse_FetchData",SHImpulseptr%,Length%,,,,,mytask%
  20343.  mergetag%:
  20344.  ### Merging application replies when all data in document merged ###
  20345. selected(mergeW%,3) 
  20346.  "Impulse_SendMessage",&201,":"+$mergewith%+"."+document$+" Print",,,,printtag%,mytask%
  20347. display(key%,addr)
  20348.  printtag%:
  20349.  ### Merging application has printed the current document ###
  20350. 1  mergenum%+=1:$
  20351. text(mergeW%,7)=
  20352. (mergenum%)
  20353. redraw_icon(mergeW%,7)
  20354. selected(mergeW%,3) 
  20355.  finished% 
  20356.  addr=
  20357. moveto(key%,addr,direction%)
  20358. abort_merge
  20359. close_file(dbasehandle%)
  20360. addr=ClientPtr%:merging%=
  20361. deselect(mergeW%,3)
  20362. close_it(mergeW%)
  20363. softerror("",27)
  20364. wimp_error(
  20365. Impulse_send(tag%,maxsize%)
  20366.  send%,flag%
  20367.  tag%<>transtag% 
  20368.  moan_err%,
  20369. msg("Err216"):
  20370.  datalength%>maxsize%:
  20371.   send%=maxsize%
  20372.   datalength%-=maxsize%
  20373.   flag%=
  20374.  datalength%=0 
  20375.  send%=0 
  20376.  send%=maxsize%
  20377.  datalength%<maxsize%
  20378.     transptr%!datalength%=0
  20379.     datalength%+=4
  20380.   datalength%=0  
  20381.  "Impulse_TransmitData",transptr%,send%,,,,,mytask%
  20382.  flag% 
  20383.  transptr%+=send%
  20384. Impulse_receive(replytag%,expected%,received%)
  20385.  I%,F%,P%
  20386. transbuff%=SHImpulseptr%
  20387. transbuff%?received%=13
  20388. data$=$transbuff%
  20389.  ### Acknowledge data received (get reason code 19 otherwise!) ###
  20390.  "Impulse_SendMessage",&202,,,,,replytag%,mytask%
  20391.  data$<>"" 
  20392.   P%=
  20393. data$,"#")
  20394.   REC%=
  20395. data$,P%-1))
  20396.   data$=
  20397. data$,P%+1)
  20398.  REC%=-1 
  20399.  REC%=RA%
  20400. read(
  20401. ,fields%,REC%<>RA%,REC%,$database%)
  20402.  I%=1 
  20403. (ClientForm$) 
  20404. $    F%=
  20405. fnum(
  20406. ClientForm$,I%,2))
  20407. <    
  20408.  data$<>"" 
  20409.  $Rf%(F%)=
  20410. get_string(data$,ClientSep$)
  20411. write(fields%,key%)
  20412.  received%=0 
  20413.  "Impulse_SendMessage",&201,"GetRecord",,,,getrec%,mytask%
  20414. get_string(
  20415.  S$,sep$)
  20416.  P%,F$
  20417. S$,sep$)
  20418.  P%>0 
  20419.   F$=
  20420. S$,P%-1)
  20421.   S$=
  20422. S$,P%+1)
  20423. stripright(F$," ")
  20424. prepare_next_record(key$,transbuff%)
  20425.  ok%,I%,F%,P%
  20426.  dbasehandle%=0 
  20427. ,  dbasehandle%=
  20428. ($database%+".Database")
  20429. '  ClientPtr%=
  20430. neighbour(key%,top,1)
  20431. P%=transbuff%
  20432.  key$ 
  20433.  "***":
  20434. close_file(dbasehandle%)
  20435.   $P%=key$:P%+=
  20436. ($P%)+1
  20437.  ok%=
  20438.  ClientPtr%<>top
  20439. (    REC%=
  20440. rec_no(k$,key%,ClientPtr%)
  20441. '    
  20442. readsmarray(dbasehandle%,REC%)
  20443. (ClientSearch$)=
  20444. $      $P%=
  20445. (REC%)+"#":P%+=
  20446. ($P%)
  20447. :    %      
  20448.  I%=1 
  20449. (ClientForm$) 
  20450. (        F%=
  20451. fnum(
  20452. ClientForm$,I%,2))
  20453. ,        $P%=F$(F%)+ClientSep$:P%+=
  20454. ($P%)
  20455.       
  20456.       ok%=
  20457.         
  20458. 0    ClientPtr%=
  20459. neighbour(key%,ClientPtr%,1)
  20460.  P%=transbuff% 
  20461. close_file(dbasehandle%)
  20462. "  val$=
  20463. type(key%):kl%=
  20464. (key$)
  20465. %  ClientPtr%=
  20466. search(key$,key%,1)
  20467.  ClientPtr%>=0 
  20468. (    REC%=
  20469. rec_no(k$,key%,ClientPtr%)
  20470. '    
  20471. readsmarray(dbasehandle%,REC%)
  20472. "    $P%=
  20473. (REC%)+"#":P%+=
  20474. ($P%)
  20475. #    
  20476.  I%=1 
  20477. (ClientForm$) 
  20478. &      F%=
  20479. fnum(
  20480. ClientForm$,I%,2))
  20481. *      $P%=F$(F%)+ClientSep$:P%+=
  20482. ($P%)
  20483.     $P%+=ClientSep$:P%+=1
  20484. =P%-transbuff%
  20485. prepare_next_field(method%,S$)
  20486.  C%,L%,F%,P%,len%,T$,F$,V%,R%,b$,k$,SF$,blobloaded%,X%,exp$
  20487.  method%=8 
  20488.   P%=
  20489. S$,",")
  20490. :&(  
  20491.  P%>0 
  20492.  exp$=
  20493. S$,P%):S$=
  20494. S$,P%-1)
  20495. :('F%=
  20496. field(X%,S$,
  20497. ):V%=chartype%(F%)
  20498. :*z  
  20499.  0,1,2,3,4,5,6,7,8,46,47,48,49,50,51,52,53,54,55,56,57,58,63,68,69,70,71,72,73,74,75,76,77,78,79:F$=F$(F%):L%=
  20500. :+#  
  20501.  method%=8 
  20502.  link$(F%)<>"" 
  20503. :,<    F$=
  20504. expand(F$(F%),link$(F%)+exp$,L%,SF$,C%):L%=
  20505.  36,39:
  20506.   R%=
  20507. rec_no(k$,key%,addr)
  20508. :0-  L%=
  20509. blob_path(
  20510. ,$database%,R%,F%,V%,b$)
  20511.  L%>0 
  20512. :27    SHImpulseptr%=
  20513. claim_page(transanchor%,L%+1024)
  20514. :3<    
  20515.  "OS_File",255,b$,SHImpulseptr%:SHImpulseptr%?L%=0
  20516.     blobloaded%=
  20517. :62  
  20518.  41,42,43,61,62:F$=F$(F%):L%=
  20519. no_yes(F%,F$)
  20520.  blobloaded% 
  20521.  $SHImpulseptr%=F$ 
  20522.  SHImpulseptr%?L%=0:L%+=1
  20523. len%=(L%+4) 
  20524.  &FFFFFFFC
  20525.  L%<len%
  20526.   SHImpulseptr%?L%=0
  20527.   L%+=1
  20528. transptr%=SHImpulseptr%
  20529. :?    =len%
  20530. start_merge(wi%)
  20531. Impulse_wait%=
  20532. text(wi%,1)=document$:
  20533. redraw_icon(wi%,1)
  20534. text(wi%,4)="Merge"
  20535. text(wi%,6)="":$
  20536. text(wi%,7)=""
  20537. deselect(wi%,12)
  20538. position_window(wi%,-1,-1,0,0,0,0)
  20539. set_caret(0,wi%,9)
  20540. finished%=
  20541. merge_next(filter%,key%,P%)
  20542.  S$,J%,F%,F1%
  20543. complete(5)
  20544.  P%=top 
  20545.  finished% 
  20546. selected(mergeW%,3) 
  20547.  filter% 
  20548. :R.    dbasehandle%=
  20549. ($database%+".Database")
  20550. :S#    record%=
  20551. rec_no(k$,key%,P%)
  20552. :T*    
  20553. readsmarray(dbasehandle%,record%)
  20554. :U!    
  20555. close_file(dbasehandle%)
  20556.  J%=0 
  20557. :X:    F1%=KF%(key%,J%):
  20558.  F1%<>F% 
  20559.  F%=F1%:S$+=F$(F%)+" "
  20560. :Z7  $
  20561. text(mergeW%,6)=
  20562. S$,80):
  20563. redraw_icon(mergeW%,6)
  20564. :[d  
  20565.  "Impulse_SendMessage",&201,":"+$mergewith%+"."+document$+" Merge",0,0,0,mergetag%,mytask%,0
  20566.  End of "Impulse" handling -------------------------------------------
  20567.  Import/Export CSV files ---------------------------------------------
  20568. start_import(type$,wi%)
  20569.  T%,F,filename$,S$,fieldinfo%
  20570. filename$=$
  20571. text(csvW%,13)
  20572. :f(F=
  20573. (filename$):S$=
  20574. close_file(F)
  20575. fieldinfo%=(
  20576. S$,"|")>0)
  20577.  fieldinfo%=
  20578.  present%=0 
  20579. softerror("",69):
  20580.  fieldinfo%=
  20581.  present%>0 
  20582. softerror("",172):
  20583.  present%=7 
  20584.  Modify%=
  20585. softerror("",14):
  20586.  "Wimp_GetPointerInfo",,block%:x%=!block%:y%=block%!4
  20587.  T%=0 
  20588.  LastTable%
  20589. :m)  
  20590.  wi%=tableW%(T%) 
  20591.  Tablenumber%=T%
  20592.  wi% 
  20593. :p   
  20594.  -2:csvfunc$="ImportMain"
  20595. :qH  
  20596.  present%=0 
  20597. select(csvW%,1):
  20598. select(csvW%,4):
  20599. shade(csvW%,4,
  20600. :r+  
  20601.  mainW%,markW%:csvfunc$="ImportMain"
  20602. :s4  
  20603.  tableW%(Tablenumber%):csvfunc$="ImportTable"
  20604. :t7  
  20605.  scrollerW%(Scroller%):csvfunc$="ImportScroller"
  20606. filename$=$
  20607. text(csvW%,13)
  20608. shade(csvW%,0,
  20609. :x&$CSVTitle%="Import "+type$+" file"
  20610. text(csvW%,9)="Import"
  20611.  wi%=mainW% 
  20612. :{5  
  20613. position_window(csvW%,x%-350,y%-260,0,570,0,0)
  20614. :|+  
  20615. position_window(csvW%,0,0,0,0,0,0)
  20616. auto_csv(on%)
  20617.  R4%,f$,S$,vers%
  20618.  on% 
  20619.  present%=7 
  20620.  $Reformatted%="" 
  20621. "    f$=$database%+".PrintJobs"
  20622.  R4%<>-1
  20623. 8      
  20624.  "OS_GBPB",9,f$,block%,1,R4%,255 
  20625.  ,,S$,,R4%
  20626. .      
  20627. S$,7)="NewData" 
  20628.  vers%=
  20629. S$,2))
  20630.         
  20631. )    f$+=".NewData"+
  20632. (vers%+1),2)
  20633.     autocsvhandle%=
  20634.  "OS_File",18,f$,&dfe
  20635. "    
  20636. select_range(1,fields%,
  20637.     csvform$=printorder$
  20638. clear_selection
  20639.  autocsvhandle%>0 
  20640. close_file(autocsvhandle%)
  20641. write_csv(Filename$,displayed%)
  20642.  P%,rec%,examined%,subtotal%,sel$,default% 
  20643.  writingcsv% 
  20644.  printorder$="" 
  20645. ,  sel$=$database%+".PrintRes.!Selection"
  20646.  "OS_File",5,sel$ 
  20647.  default%
  20648.  default%=1 
  20649. load_selection(sel$)
  20650.  printorder$<>"" 
  20651. selected(csvW%,3) 
  20652.  Form$=printorder$ 
  20653. softerror("",34):
  20654. end_csv:
  20655. *s$=$
  20656. text(printW%,26):s%=
  20657. (s$):c$=
  20658.  s%=0:spacer$=s$
  20659.  c$<"0" 
  20660.  c$>"9":spacer$=
  20661. s%,c$)
  20662. :spacer$=
  20663. s%," ")
  20664. )csvhandle%=
  20665. (Filename$):writingcsv%=
  20666. selected(csvW%,1) 
  20667. csv_head
  20668. *dbasehandle%=
  20669. ($database%+".Database")
  20670. Search$=
  20671. parse
  20672. !direc%=
  20673. selected(queryW%,4)+1
  20674.  displayed%>=0:
  20675. readsmarray(dbasehandle%,displayed%)
  20676. write_csv_rec(REC%,Form$,csvhandle%)
  20677.  usekey%=-1,
  20678. selected(savesubW%,6):
  20679. scan_marked_subfiles("P%<>top",key%,3,direc%,
  20680. scan_marked_subfiles("P%<>top AND k$=useval$",usekey%,3,1,
  20681. close_file(csvhandle%)
  20682. close_file(dbasehandle%)
  20683.  "OS_File",18,Filename$,&dfe
  20684. writingcsv%=
  20685. close_it(savesubW%)
  20686.  default%=1 
  20687. clear_selection
  20688. end_csv
  20689.  "Hourglass_Smash"
  20690. close_file(csvhandle%)
  20691. close_file(dbasehandle%)
  20692.  "OS_File",18,Filename$,&dfe
  20693. writingcsv%=
  20694. softerror("",41)
  20695. wimp_error(
  20696. csv_head
  20697.  I%,F%,f$,H$,Head$,N%
  20698.     I%=-1
  20699. (Form$)-1
  20700. (  I%+=2:F%=
  20701. fnum(
  20702. Form$,I%,2)):N%+=1
  20703. selected_esg(printW%,1) 
  20704.  1:Head$=Tag$(F%)
  20705. ,    
  20706.  2:Head$=$
  20707. text(mainW%,(desc%(F%)))
  20708.  36:Head$=""
  20709. selected(csvW%,4) 
  20710.  Head$=
  20711. (chartype%(F%))+"|"+
  20712. (len%(F%))+"|"+$
  20713. text(mainW%,(desc%(F%)))+"|"+Tag$(F%)
  20714.  chartype%(F%)<>3 
  20715.  chartype%(F%)<>6 
  20716. selected(csvW%,0) 
  20717.  Head$=""""+Head$+""""
  20718.  N%>1 
  20719.  Head$=sep$+Head$
  20720. #csvhandle%,Head$;
  20721. #csvhandle%,term$;
  20722. write_csv_rec(R%,Form$,handle%)
  20723.  C%,I%,F%,f$,F$,L%,N%,V%,filename$,len%,base%,SF$,first%,pending%
  20724. selected(csvW%,3) 
  20725.   F$=
  20726. key2(0,1)
  20727.   F$=
  20728. add_quotes(F$)
  20729.  Form$<>"" 
  20730.  F$+=sep$
  20731. #handle%,F$;
  20732. selected(csvW%,22) 
  20733. #handle%,
  20734. (REC%)+sep$;
  20735. I%=-1:L%=
  20736. (Form$)-1
  20737. first%=
  20738.  I%<L%
  20739. "  I%+=2:F%=
  20740. fnum(
  20741. Form$,I%,2))
  20742.  concat% 
  20743.  first%:
  20744. =    F$=F$(F%):
  20745.  F$<>"" 
  20746. selected(csvW%,2) 
  20747.  F$+=spacer$
  20748.     pending%=
  20749. :first%=
  20750.  concat%:
  20751. >    
  20752.  F$(F%)<>"" 
  20753. selected(csvW%,2) 
  20754.  F$+=F$(F%)+spacer$
  20755.     pending%=
  20756.  pending%:
  20757. 6    
  20758.  F$(F%)<>"" 
  20759. selected(csvW%,2) 
  20760.  F$+=F$(F%)
  20761.     pending%=
  20762. :first%=
  20763.     n%=
  20764. (spacer$)
  20765. ,    
  20766. F$,n%)=spacer$ 
  20767. (F$)-n%)
  20768.     N%+=1
  20769. '    
  20770.  F$<>"" 
  20771. selected(csvW%,2) 
  20772.       F$=
  20773. add_quotes(F$)
  20774.       
  20775.  N%>1 
  20776.  F$=sep$+F$
  20777.       
  20778. #handle%,F$;
  20779.         
  20780.     V%=chartype%(F%)
  20781.       
  20782.  36,39:
  20783. .      len%=
  20784. load_blob($database%,R%,F%,36)
  20785. )      
  20786.  len%>0 
  20787. selected(csvW%,2) 
  20788. *        N%+=1:
  20789.  N%>1 
  20790. #handle%,sep$;
  20791. 2        
  20792. selected(csvW%,0) 
  20793. #handle%,"""";
  20794. '        
  20795. blob_to_file(handle%,len%)
  20796. 2        
  20797. selected(csvW%,0) 
  20798. #handle%,"""";
  20799.       
  20800. .      
  20801.  3,6,46,47,54,56,57,74,75,77,78,79:
  20802.       F$=F$(F%):N%+=1
  20803. )      
  20804.  F$<>"" 
  20805. selected(csvW%,2) 
  20806.         
  20807.  N%>1 
  20808.  F$=sep$+F$
  20809.         
  20810. #handle%,F$;
  20811.       
  20812.       
  20813.  41,42,43,61,62:
  20814.         F$=F$(F%):N%+=1
  20815.         Z%=
  20816. no_yes(F%,F$)
  20817.         F$=
  20818. add_quotes(F$)
  20819.         
  20820.  N%>1 
  20821.  F$=sep$+F$
  20822.         
  20823. #handle%,F$;
  20824.       
  20825.  64,65,66,67:
  20826. (      N%+=1:
  20827.  N%>1 
  20828. #handle%,sep$;
  20829. 0      
  20830. selected(csvW%,0) 
  20831. #handle%,"""";
  20832. !      S%=
  20833. scroller_number(F%)
  20834.       pending%(S%)=
  20835.       
  20836.  pending%(S%)
  20837. :        F$=
  20838. read_scroller_row(REC%,F%,S%,V%-63,
  20839. ,sep$)
  20840. )        
  20841. selected_esg(printW%,6) 
  20842.           
  20843. /          
  20844.  pending%(S%) 
  20845.  F$+=scrollterm$ 
  20846.           
  20847. #handle%,F$;
  20848.           
  20849.           
  20850. #handle%,F$;
  20851.           
  20852.  pending%(S%) 
  20853. R            
  20854. selected(csvW%,0) 
  20855. #handle%,""""+sep$+""""; 
  20856. #handle%,sep$;
  20857.           
  20858.         
  20859.       
  20860. ;"0      
  20861. selected(csvW%,0) 
  20862. #handle%,"""";
  20863.       
  20864. ;$"      
  20865. selected(printW%,5) 
  20866. ;%4        F$=
  20867. expand(F$(F%),link$(F%),Len%,SF$,C%)
  20868.         
  20869.  F$=F$(F%)
  20870.       
  20871.       N%+=1
  20872. ;))      
  20873.  F$<>"" 
  20874. selected(csvW%,2) 
  20875.         F$=
  20876. add_quotes(F$)
  20877.         
  20878.  N%>1 
  20879.  F$=sep$+F$
  20880.         
  20881. #handle%,F$;
  20882.       
  20883. ;.        
  20884. #handle%,term$;
  20885. add_quotes(F$)
  20886. selected(csvW%,0) 
  20887. =""""+F$+"""" 
  20888. convert_csv(f$)
  20889.  k$,B%,J%,fld%,S$,sep%,sep2%,term%,term2%,F$,avail%,nextfree%,keybase%,base%,base2%,show%,done%,display%,abort%
  20890.  importingcsv% 
  20891. importingcsv%=
  20892. stop_reading:
  20893. ;==SHmisc%=
  20894. extend_named_sliding_block(tempanchor%,SHclaim%)
  20895. ;>:sep%=
  20896. (sep$):
  20897. (sep$)=2 
  20898.  sep2%=
  20899. sep$)) 
  20900.  sep2%=255
  20901. ;?@term%=
  20902. (term$):
  20903. (term$)=2 
  20904.  term2%=
  20905. term$)) 
  20906.  term2%=255
  20907. csvhandle%=
  20908.  present%=0 
  20909. csv_to_dbase(f$):
  20910.  abort% 
  20911. Form$=
  20912. csv_importform
  20913. ;C3toobighandle%=
  20914. ($database%+".PrintJobs.TooBig")
  20915.  "Hourglass_On"
  20916. ;E display%=
  20917. selected(csvW%,11)
  20918. limit_actions(
  20919. ,multitask%)
  20920. selected(csvW%,24) 
  20921.  addr=top
  20922. ;J7    
  20923. selected(csvW%,24):
  20924.  Modify existing records
  20925. ;K$    addr=
  20926. neighbour(key%,addr,1)
  20927. ;L/    
  20928.  addr=top 
  20929.  moan_err%,
  20930. msg("Err131")
  20931. ;M"    REC%=
  20932. rec_no(k$,key%,addr)
  20933. ;N1    
  20934. read(display%,fields%,
  20935. ,REC%,$database%)
  20936. ;O2    
  20937. selected(csvW%,22):
  20938.  With record number
  20939. read_bytes
  20940.     REC%=
  20941. ($base%)
  20942. ;R1    
  20943. read(display%,fields%,
  20944. ,REC%,$database%)
  20945. ;S/    
  20946. selected(csvW%,3):
  20947.  With primary key
  20948. read_bytes
  20949. ;U*    addr=
  20950. find(
  20951. $base%,KL%(key%)),0,
  20952.  addr>0 
  20953. ;W$      REC%=
  20954. rec_no(k$,key%,addr)
  20955. ;X3      
  20956. read(display%,fields%,
  20957. ,REC%,$database%)
  20958.       
  20959. make_new_rec
  20960. ;Z        
  20961. make_new_rec
  20962.   endline%=
  20963. :J%=-1
  20964. ;^#  
  20965. (Form$)-2 
  20966.  endline%=
  20967. ;_&    J%+=2:fld%=
  20968. fnum(
  20969. Form$,J%,2))
  20970. ;`!    
  20971. transfer_csv_field(fld%)
  20972. ;bC  
  20973.  fld%<=fields% 
  20974.  (endline% 
  20975. #csvhandle%) 
  20976. next_csv_rec
  20977. write(fields%,key%)
  20978. ;d"  
  20979.  display% 
  20980. redraw(mainW%)
  20981. ;e?  
  20982.  "Hourglass_Percentage",
  20983. #csvhandle%*100 
  20984. #csvhandle%
  20985. #csvhandle%
  20986.  "Hourglass_Off"
  20987. close_file(csvhandle%)
  20988. close_file(toobighandle%)
  20989.  "OS_File",18,$database%+".PrintJobs.TooBig",&fff
  20990. addr=
  20991. moveto(key%,top,1)
  20992. clear_selection
  20993. asterisk(
  20994. write_log(-1,"CSV data imported from file:",f$)
  20995. importingcsv%=
  20996. save_keys
  20997. limit_actions(Access%,multitask%)
  20998. make_new_rec
  20999. ;u-keybase%=SHkeyptr%(0):nextfree%=!keybase%
  21000.  !(keybase%+nextfree%)<=0 
  21001.   incr%=
  21002. ($Increment%)
  21003.  incr%>0 
  21004. ;y#    
  21005. change_length(RA%+incr%,
  21006. ;z1    keybase%=SHkeyptr%(0):nextfree%=!keybase%
  21007. ;{#    
  21008.  moan_err%,
  21009. msg("Err66")
  21010. ;~)REC%=!(keybase%+nextfree%+8+KL%(0)+1)
  21011. read(display%,fields%,
  21012. ,RA%,$database%)
  21013. transfer_csv_field(
  21014.  fld%)
  21015.  C%,L%,P%,Q%,R%,T%,R$,S$,ic%,wi%,p%,z$
  21016.  chartype%(fld%) 
  21017.  64,65,66,67:
  21018. read_bytes
  21019.  ptr%>0 
  21020. 4    S%=
  21021. scroller_number(fld%):wi%=scrollerW%(S%)
  21022. 8    cols%=scrolldata%(S%,8):icons%=scrolldata%(S%,6)
  21023. (    P%=-1:Q%=base%:T%=
  21024. (scrollterm$)
  21025.         
  21026.       
  21027.         P%+=1
  21028. !      
  21029.  base%?P%=T% 
  21030.  P%=ptr%
  21031. *      base%?P%=13:R$=$Q%:Q%=base%+P%+1
  21032.       
  21033.  C%=0 
  21034.  cols%-1
  21035. 2        p%=
  21036. R$,sep$):S$=
  21037. R$,p%-1):R$=
  21038. R$,p%+1)
  21039. ,        ic%=R%*cols%+C%:L%=sclen%(S%,C%)
  21040. I        
  21041.  ic%=icons%-1 
  21042.  P%<ptr% 
  21043.  icons%=
  21044. add_row(S%,wi%,R%+2,cols%)
  21045. #        $
  21046. text(wi%,ic%)=
  21047. S$,L%)
  21048.       
  21049.       R%+=1
  21050.  P%=ptr%
  21051. "    
  21052. write_scroller(REC%,fld%)
  21053.  36,39:
  21054. read_bytes
  21055.  ptr%>0 
  21056. 3    Z%=
  21057. blob_path(
  21058. ,$database%,REC%,fld%,36,F$)
  21059. $    Start%=base%:End%=base%+ptr%
  21060. "    
  21061. save(F$,&fff,Start%,End%)
  21062.  display% 
  21063.       
  21064.  chartype%(fld%) 
  21065. ?        
  21066. set_blob_sprite(REC%,fld%,chartype%(fld%),z$)
  21067. ,        
  21068. show_text_block(fld%,REC%)
  21069.       
  21070.         
  21071.  41,42,43,61,62:
  21072. read_bytes:c$=
  21073. pos_neg(fld%,$base%)
  21074. F    
  21075.  " ":$Rf%(fld%)=" ":
  21076.  display% 
  21077. select(mainW%,field%(fld%))
  21078. F    
  21079.  "":$Rf%(fld%)="":
  21080.  display% 
  21081. deselect(mainW%,field%(fld%))
  21082.  "@":
  21083. #toobighandle%,"Rec."+
  21084. (REC%)+",Fld."+
  21085. (fld%)+","+$base%+" unsuitable data for check-box":$Rf%(fld%)="":
  21086. deselect(mainW%,field%(fld%))
  21087.  0,1,2,3,4,5,6,7,8,46,47,48,49,50,51,52,53,54,55,56,57,58,60,63,68,69,70,71,72,73,74,75,76,77,78,79:
  21088.  len%(fld%)>0 
  21089. read_bytes
  21090. >    
  21091. selected(csvW%,16) 
  21092.  $base%=
  21093. stripright($base%," ")
  21094.       
  21095.  ptr%<=len%(fld%):
  21096.        
  21097.  chartype%(fld%)=47 
  21098. H        
  21099. selected(csvW%,23) 
  21100.  $Rf%(fld%)=$base%:dontincrement%=
  21101.         
  21102.  $Rf%(fld%)=$base%
  21103.       
  21104.       
  21105.  ptr%<247:
  21106. C      
  21107. #toobighandle%,"Rec."+
  21108. (REC%)+",Fld."+
  21109. (fld%)+","+$base%
  21110.       $Rf%(fld%)="@"
  21111.       
  21112.       
  21113. #toobighandle%,"Rec."+
  21114. (REC%+1)+",Fld."+
  21115. (fld%)+" is more than 246 characters long. Data not saved. External field suggested."
  21116.       $Rf%(fld%)="@"
  21117.         
  21118.  fld%+=1
  21119. 8    
  21120.  ### Zero-length field is probably just a label
  21121. :fld%+=1
  21122.  ### Can't put CSV data into Button, Sprite or Draw fields! ###
  21123.  changed%=
  21124. update_calcs(fld%)
  21125. read_bytes
  21126.  end$,B%
  21127. base%=!tempanchor%
  21128. ptr%=-1
  21129. #csvhandle%
  21130.  B%=34 
  21131. O  end$="(B%=sep% OR B%=term% OR EOF#csvhandle%=TRUE) AND base%?(ptr%-1)=34"
  21132. 7  end$="B%=sep% OR B%=term% OR EOF#csvhandle%=TRUE"
  21133. #csvhandle%=
  21134. #csvhandle%-1
  21135.   B%=
  21136. #csvhandle%
  21137.   ptr%+=1:base%?ptr%=B%
  21138. (end$)
  21139.  base%?(ptr%-1)=34 
  21140.  ptr%-=1
  21141. base%?ptr%=13
  21142.  sep%:
  21143. skip_sep
  21144.  term%:
  21145. skip_term
  21146. next_csv_rec
  21147.   B%=
  21148. #csvhandle%
  21149.  B%=term%
  21150. skip_term
  21151. skip_sep
  21152.  sep2%<>255 
  21153.   B%=
  21154. #csvhandle%
  21155.  B%<>sep2% 
  21156. #csvhandle%=
  21157. #csvhandle%-1
  21158. skip_term
  21159.  term2%<>255 
  21160.   B%=
  21161. #csvhandle%
  21162.  B%<>term2% 
  21163. #csvhandle%=
  21164. #csvhandle%-1 
  21165.  endline%=
  21166.  endline%=
  21167. stop_reading
  21168.  "Hourglass_Off"
  21169. close_file(csvhandle%)
  21170. close_file(toobighandle%)
  21171. close_file(dbasehandle%)
  21172.  "OS_File",18,$database%+".PrintJobs.TooBig",&fff
  21173.  =17 
  21174. softerror("",74)
  21175. wimp_error(
  21176.  present%=7 
  21177.   addr=
  21178. moveto(key%,top,1)
  21179. clear_selection
  21180. importingcsv%=
  21181. limit_actions(Access%,multitask%)
  21182. csv_importform
  21183.  F%,f$,F$,X%,m$
  21184. endline%=
  21185. selected(csvW%,1):
  21186.  ### Use header record to build form ###
  21187. read_bytes
  21188. %    
  21189. selected_esg(printW%,1) 
  21190. -      
  21191.  1:F%=
  21192. field(X%,$base%,
  21193. ):m$="tag"
  21194. 0      
  21195.  2:F%=
  21196. dfield($base%):m$="descriptor"
  21197. )      
  21198.  moan_err%,
  21199. msg("Err136")
  21200. 9    
  21201.  F%=0 
  21202.  moan_err%,
  21203. msg("Err87,"+m$+","+$base%)
  21204.     f$=
  21205. ~(F%)
  21206. (f$)=1 
  21207.  f$="0"+f$
  21208.     F$+=f$
  21209. "    
  21210. invert(mainW%,field%(F%))
  21211.  endline%
  21212.  printorder$<>"":
  21213.  ### Build form from highlighted fields, as in printing ###
  21214.   F$=printorder$
  21215.  ### Assume entry into all fields, beginning with first ###
  21216.  F%=1 
  21217.  fields%
  21218.     f$=
  21219. ~(F%)
  21220. (f$)=1 
  21221.  f$="0"+f$
  21222.     F$+=f$
  21223. csv_to_dbase(f$)
  21224.  F%,L%,LM%,P%,Q%,V%,F,S$,readpos%,width%
  21225.  Desc$()
  21226.  Desc$(MaxFields%)
  21227. read_bytes:S$=$base%:
  21228. #csvhandle%=0
  21229. S$,"|")=0 
  21230.  moan_err%,
  21231. msg("Err89")
  21232. leaf$=
  21233. leaf(f$):csvconv%=
  21234.  $database%="No data" 
  21235.  $database%=leafnamepath$+".!"+leaf$
  21236. save($database%,0,0,0)
  21237. fields%=0:endline%=
  21238.   fields%+=1
  21239. read_bytes:S$=$base%
  21240. <40  V%=
  21241. (S$):P%=
  21242. S$,"|"):S$=
  21243. S$,P%+1):L%=
  21244. <5'  
  21245.  L%>0 
  21246. S$,"|"):S$=
  21247. S$,P%+1)
  21248.  L%=0 
  21249.  L%=V%:V%=0
  21250. <7-  chartype%(fields%)=V%:len%(fields%)=L% 
  21251.   P%=
  21252. S$,"|")
  21253.  P%=0 
  21254. <:.    Desc$(fields%)=S$:Tag$(fields%)=
  21255. S$,4)
  21256. <;        
  21257. <<:    Desc$(fields%)=
  21258. S$,P%-1):Tag$(fields%)=
  21259. S$,P%+1,4)
  21260. <>&  L%=
  21261. string_width(Desc$(fields%))
  21262.  L%>LM% 
  21263.  LM%=L%
  21264.  endline%
  21265. ($database%+".Form")
  21266. #F,fields%
  21267.  F%=1 
  21268.  fields%
  21269.   xd%=16:xf%=xd%+LM%
  21270.   yd%=-(F%*52):yf%=yd%
  21271. <F@  bbox%=
  21272. guess_width(len%(F%),chartype%(F%),width%)+(48<<16)
  21273. <GK  
  21274. #F,Desc$(F%),Tag$(F%),xd%,yd%,xf%,yf%,len%(F%),chartype%(F%),0,bbox%
  21275. close_file(F)
  21276.  "OS_File",18,$database%+".Form",&7f2
  21277. fields%=0:Fieldnumber%=0
  21278. fields%=
  21279. get_form(Fptr%)
  21280. default_key
  21281. readpos%=
  21282. #csvhandle%
  21283. no_of_recs
  21284. defaults($database%,RA%,0)
  21285.  abort% 
  21286.  present%=0:importingcsv%=
  21287. save_keys
  21288. deselect(csvW%,1)
  21289. csvhandle%=
  21290. #csvhandle%=readpos%
  21291. <V=SHmisc%=
  21292. extend_named_sliding_block(tempanchor%,SHclaim%)
  21293. no_of_recs
  21294.  N%,B%
  21295. #csvhandle%
  21296.  B%=term% 
  21297. #csvhandle%
  21298.   N%+=1
  21299. <_?  
  21300.  "Hourglass_Percentage",
  21301. #csvhandle%*100 
  21302. #csvhandle%
  21303. #csvhandle%
  21304. table_to_csv(T%,Filename$)
  21305.  Rows%,TabFields%,Rec%,offset%,heading%,colours$
  21306. <eUt$=
  21307. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  21308. save_as_csv(Filename$,tableW%(T%),Rows%,TabFields%)
  21309. writetable%=
  21310. scroller_to_csv(S%,f$)
  21311.  wi%,F%,icons%,cols%
  21312. wi%=scrollerW%(S%)
  21313. F%=scrolldata%(S%,0)
  21314. icons%=scrolldata%(S%,6)
  21315. cols%=scrolldata%(S%,8)
  21316. save_as_csv(f$,wi%,icons% 
  21317.  cols%,cols%-1)
  21318. writescroller%=
  21319. save_as_csv(f$,wi%,rows%,cols%)
  21320.  csvhandle%,ic%,row%,column%,F$
  21321. csvhandle%=
  21322. ic%=-1
  21323.  "Hourglass_On"
  21324.  row%=0 
  21325.  rows%-1
  21326.  column%=0 
  21327.  cols%
  21328. <{!    ic%+=1:F$=$
  21329. text(wi%,ic%)
  21330. <|.    
  21331. selected(csvW%,0) 
  21332.  F$=""""+F$+""""
  21333. <}.    
  21334.  column%<cols% 
  21335.  F$+=sep$ 
  21336.  F$+=term$
  21337. #csvhandle%,F$;
  21338.  column%
  21339.  row%
  21340.  "Hourglass_Off"
  21341. close_file(csvhandle%)
  21342.  "OS_File",18,f$,&dfe
  21343. csv_to_table(T%,filename$)
  21344.  ic%,row%,column%,Rows%,TabFields%,Rec%,offset%,heading%,csvhandle%,base%,F$,sep%,sep2%,term%,term2%
  21345. table_info(T%,Rows%,TabFields%,Rec%,tabfieldlen%(),offset%,heading%,colours$)
  21346. import_csv("T",filename$,tableW%(T%),Rows%,TabFields%)
  21347. csv_to_scroller(S%,filename$)
  21348.  wi%,F%,icons%,cols%
  21349. wi%=scrollerW%(S%)
  21350. F%=scrolldata%(S%,0)
  21351. icons%=scrolldata%(S%,6)
  21352. cols%=scrolldata%(S%,8)
  21353. import_csv("S",filename$,wi%,icons% 
  21354.  cols%,cols%-1)
  21355. ScrollChanged%=
  21356. asterisk(
  21357. import_csv(to$,f$,wi%,rows%,cols%)
  21358.  csvhandle%,sep%,sep2%,term%,term2%,base%,row%,column%,recs%,endline%
  21359. :sep%=
  21360. (sep$):
  21361. (sep$)=2 
  21362.  sep2%=
  21363. sep$)) 
  21364.  sep2%=255
  21365. @term%=
  21366. (term$):
  21367. (term$)=2 
  21368.  term2%=
  21369. term$)) 
  21370.  term2%=255
  21371. =SHmisc%=
  21372. extend_named_sliding_block(tempanchor%,SHclaim%)
  21373. base%=SHmisc%
  21374. csvhandle%=
  21375.  to$="S" 
  21376.   recs%=
  21377. no_of_recs
  21378. #csvhandle%=0
  21379.  recs%>rows% 
  21380.  row%=rows%+1 
  21381.  recs%
  21382. .      icons%=
  21383. add_row(S%,wi%,row%,cols%+1)
  21384.  row%
  21385.     rows%=recs%
  21386.  "Hourglass_On"
  21387.  row%=0 
  21388.  rows%-1
  21389. -  endline%=
  21390. :column%=0:ic%=row%*(cols%+1)
  21391.  column%<=cols% 
  21392.  endline%=
  21393. #csvhandle% 
  21394.       
  21395. read_bytes
  21396. :      $
  21397. text(wi%,ic%)=
  21398. $base%,
  21399. buffer_length(wi%,ic%))
  21400.         
  21401.     column%+=1:ic%+=1
  21402.  (endline% 
  21403. #csvhandle%) 
  21404. next_csv_rec
  21405.  row%
  21406.  "Hourglass_Off"
  21407. close_file(csvhandle%)
  21408. redraw(wi%)
  21409. asterisk(
  21410.  --- SLIDING HEAP 2.01 PROCEDURES
  21411.  requires SlidingHeap 2.00 or later. 
  21412.  Current version is 2.01 (03-11-2002)
  21413.  Made 32-bit compatible by Christopher Bazley
  21414.  module and PROCs
  21415.  Steven Haslam 1992
  21416. _heap_slotsize
  21417.  "Wimp_SlotSize",-1,-1 
  21418. _heap_pageup(n%)
  21419.  "OS_ReadMemMapInfo" 
  21420. =(n%+R0%-1) 
  21421.  (R0%-1)
  21422. initheaps(heapsize%,slidingblocks%)
  21423. fixedheapsize%=heapsize%
  21424. Lheap_trigger%=
  21425. _heap_pageup(
  21426. +fixedheapsize%+20+20*slidingblocks%-&8000)
  21427. setslotsize(heap_trigger%)
  21428. _heap_slotsize<heap_trigger% 
  21429.  130,"Unable to initialise heap"
  21430. fixedheapbase%=
  21431. %slidingheapbase%=
  21432. +fixedheapsize%
  21433.  "OS_Heap",0,fixedheapbase%,,fixedheapsize%
  21434.  "SlidingHeap_Create",slidingheapbase%,2,slidingblocks%
  21435.  "SlidingHeap_VerifyHeap",slidingheapbase%
  21436. _heap_nextfree
  21437.  nextfree%
  21438.  "SlidingHeap_NextFree",slidingheapbase% 
  21439.  nextfree%
  21440. =nextfree%
  21441. destroyheaps
  21442. setslotsize(
  21443. -&8000)
  21444. _heap_wordup(x%)=(x%+3) 
  21445. create_anchor(name$)
  21446.  space%
  21447.  space% 4+
  21448.  name$+1
  21449. !space%=0
  21450. $(space%+4)=name$
  21451. =space%
  21452. create_named_sliding_block(anchor%,size%)
  21453.  trysize%
  21454. size%=
  21455. _heap_wordup(size%)
  21456. 7trysize%=
  21457. _heap_pageup(
  21458. _heap_nextfree+size%-&7FF4)
  21459.  trysize%>heap_trigger% 
  21460. setslotsize(trysize%)
  21461. _heap_slotsize<trysize% 
  21462. #    
  21463. setslotsize(heap_trigger%)
  21464. D    
  21465.  131,"Not enough room to create block """+$(anchor%+4)+""""
  21466.         
  21467.     heap_trigger%=trysize%
  21468.  "SlidingHeap_NewBlock",slidingheapbase%,anchor%,size%,anchor%+4
  21469.  "SlidingHeap_VerifyHeap",slidingheapbase%
  21470. scrap_block(anchor%)
  21471.  !anchor%=0 
  21472.  "SlidingHeap_ScrapBlock",slidingheapbase%,anchor%
  21473. 1trysize%=
  21474. _heap_pageup(
  21475. _heap_nextfree-&7FFC)
  21476.  trysize%<>heap_trigger% 
  21477. setslotsize(trysize%)
  21478.   heap_trigger%=trysize%
  21479. !anchor%=0
  21480.  "SlidingHeap_VerifyHeap",slidingheapbase%
  21481. setslotsize(newsize%)
  21482.  "Wimp_SlotSize",newsize%,-1
  21483. extend_named_sliding_block(anchor%,newsize%)
  21484.  !anchor%=0 
  21485. create_named_sliding_block(anchor%,newsize%):=!anchor%
  21486.  !anchor%>
  21487. _heap_nextfree 
  21488.  129,"Block beyond heap limits"
  21489. $newsize%=
  21490. _heap_wordup(newsize%)
  21491.  "SlidingHeap_DescribeBlock",slidingheapbase%,anchor% 
  21492.  ,,oldsize%
  21493. larger%=newsize%>oldsize%
  21494.  larger% 
  21495. G  trysize%=
  21496. _heap_pageup(
  21497. _heap_nextfree+(newsize%-oldsize%)-&7FFC)
  21498.  trysize%>heap_trigger% 
  21499. setslotsize(trysize%)
  21500. $    
  21501. _heap_slotsize<trysize% 
  21502. %      
  21503. setslotsize(heap_trigger%)
  21504. =      
  21505.  132,"Not enough room to extend block #"+
  21506. ~anchor%
  21507.       
  21508.        heap_trigger%=trysize%
  21509.         
  21510.  "SlidingHeap_ExtendBlock",slidingheapbase%,anchor%,newsize%
  21511. 1trysize%=
  21512. _heap_pageup(
  21513. _heap_nextfree-&7FFC)
  21514.  trysize%<>heap_trigger% 
  21515. setslotsize(trysize%)
  21516.    heap_trigger%=trysize%
  21517.  "SlidingHeap_VerifyHeap",slidingheapbase%
  21518. =!anchor%
  21519. sliding_block_size(anchor%)
  21520.  size%
  21521.  "SlidingHeap_DescribeBlock",slidingheapbase%,anchor% 
  21522.  ,,size%
  21523. =size%
  21524. claim_page(anchor%,needed%)
  21525.  oldsize%,newsize%
  21526. =.)oldsize%=
  21527. sliding_block_size(anchor%)
  21528.  needed%>oldsize% 
  21529.   newsize%=oldsize%
  21530.     newsize%+=SHclaim%
  21531.  newsize%>needed%    
  21532. =48  ptr%=
  21533. extend_named_sliding_block(anchor%,newsize%)
  21534. =5(  
  21535. clear_mem(ptr%,oldsize%,newsize%)
  21536. =!anchor%
  21537. clear_mem(ptr%,start%,end%)
  21538.  I%=start% 
  21539.  end%-4 
  21540.   ptr%!I%=&20202020
  21541. print_init(dest$)
  21542.  S%,Z%
  21543. check_record
  21544. =C@SHheadptr%=
  21545. extend_named_sliding_block(headanchor%,SHclaim%)
  21546. =D@SHtextptr%=
  21547. extend_named_sliding_block(textanchor%,SHclaim%)
  21548. =E>SHrecptr%=
  21549. extend_named_sliding_block(recanchor%,SHclaim%)
  21550. clear_mem(SHheadptr%,0,
  21551. sliding_block_size(headanchor%))
  21552. clear_mem(SHtextptr%,0,
  21553. sliding_block_size(textanchor%))
  21554. clear_mem(SHrecptr%,0,
  21555. sliding_block_size(recanchor%))
  21556. read_print_options(dest$,printW%,printerW%)
  21557. =J Count%=0:TextPtr%=SHtextptr%
  21558.  S%=0 
  21559.  Scrollnum%-1
  21560.   scrolldata%(S%,9)=0
  21561. =NBmaxlen%()=len%():truelen%()=0:diff%()=0:Tab2%()=0:maxlenP%()=0
  21562. =O-LenLineP%=0:pagecolumn%=0:header_lines%=0
  21563. direct_print(from%,to%)
  21564.  I%,L%,N%,lastprintable%,term%,S$,M$,more%
  21565.  pause% 
  21566.   pagenumber%>1 
  21567. =Uc  
  21568. confirm(
  21569. msg("Err219,"+
  21570. (pagenumber%))) 
  21571.  moan_err%,
  21572. msg("Err220") 
  21573.  "Hourglass_On"
  21574. fit_page
  21575.  format$="vert" 
  21576.  LenLineP%=xlimit% 
  21577.  LenLineP%=
  21578. (maxlenP%())
  21579. term%=xlimit% 
  21580.  pointsize%
  21581.  term%>400 
  21582.  term%=400
  21583.  term%>LenLine% 
  21584.  term%=LenLine%-1
  21585.  LenLineP%>xlimit% 
  21586. =]/  newsize%=(pointsize%*xlimit%) 
  21587.  LenLineP%
  21588. =^G  
  21589.  newsize%<6 
  21590. msg("Err196") 
  21591. msg("Err197,"+
  21592. (newsize%))
  21593.  format$ 
  21594.  "horiz","table":
  21595. =a        
  21596. =b8      lastprintable%+=1:L%+=maxlenP%(lastprintable%)
  21597. =c2    
  21598.  lastprintable%=PrintFields% 
  21599.  L%>xlimit%
  21600.  L%>xlimit% 
  21601.       S$=" "
  21602. =f,      
  21603.  I%=lastprintable% 
  21604.  PrintFields%
  21605. =g(        F%=
  21606. fnum(
  21607. Form$,(2*I%)-1,2))
  21608.         S$+=Tag$(F%)+"\"
  21609.       
  21610.       S$=
  21611. =k3      
  21612.  lastprintable%<PrintFields% 
  21613.  S$="s"+S$
  21614. =l        
  21615.  "vert":
  21616.  I%=1 
  21617.  PrintFields%
  21618. =o&      F%=
  21619. fnum(
  21620. Form$,(2*I%)-1,2))
  21621. =p;      
  21622.  maxlen%(F%)>L% 
  21623.  L%=maxlen%(F%):S$=" "+Tag$(F%)
  21624.  pagenumber%=1 
  21625. =ti    
  21626. confirm(
  21627. msg("Err95,"+
  21628. (pointsize%)+","+S$+","+M$))=
  21629.  printing%=
  21630.  moan_err%,
  21631. msg("Err220")
  21632. =v#  
  21633.  lastprintable%=PrintFields%
  21634.  format$="table" 
  21635.  xstart%+=4
  21636.  "ColourTrans_SetGCOL",0,0,0,0,0
  21637.  rect%=1 
  21638.  printcolumns%
  21639.   origin%=origin%(rect%)
  21640. =|U  
  21641.  "PDriver_GiveRectangle",rect%,rectangle%,transform%,origin%(rect%),&FFFFFF00
  21642.  rect%
  21643.  "PDriver_DrawPage",copies%,rectangle2%,0,0 
  21644.  more%,,rect%
  21645.  more%
  21646. (  first%=from%+pagelength%*(rect%-1)
  21647.  to%-first%+1<pagelength% 
  21648.  last%=to% 
  21649.  last%=first%+pagelength%-1
  21650. )  TextPtr%=SHtextptr%+first%*LenLine%
  21651. draw_page
  21652.  "PDriver_GetRectangle",,rectangle2% 
  21653.  more%,,rect%
  21654.  sorton%=0 
  21655. 4  Count%=0:labcount%=0:pagecolumn%=0:Label$()=""
  21656. B  SHtextptr%=
  21657. extend_named_sliding_block(textanchor%,SHclaim%)
  21658. clear_mem(SHtextptr%,0,
  21659. sliding_block_size(textanchor%))
  21660.   TextPtr%=!textanchor%
  21661. draw_page
  21662.  line%,xmax%,ymin%,rows%
  21663. &rows%=last%-first%-header_lines%+2
  21664. -ymin%=ystart%-(last%-first%)*linedepth%-8
  21665.  format$ 
  21666.  "label":
  21667. print_labels(xstart%,ystart%)
  21668.  line%=first% 
  21669.  last%
  21670. *    
  21671. print_line(xstart%,ystart%,xmax%)
  21672.     TextPtr%+=LenLine%
  21673.  line%
  21674.  format$ 
  21675.  "table":
  21676. table_grid(xmax%+spacerlen%,ymin%,rows%,tablecolumns%,tablecolumnwidth%)
  21677.  "horiz":
  21678.  vrules% 
  21679.     h%=linedepth%*(rows%+1)
  21680. #    x%=xstart%-(spacerlen% 
  21681.     y%=ymin%+22
  21682. !    
  21683. vertical_rules(x%,y%,h%)
  21684. print_line(x0%,y0%,
  21685.  xmax%)
  21686.  F%,P%,R%,chars%,width%,x%,x1%,y%,w%,font%,colour%,ptr%
  21687. +x%=x0%:y%=y0%-(line%-first%)*linedepth%
  21688. 0SHrecptr%=!recanchor%:R%=SHrecptr%!(line%*4)
  21689.  -1,-2:font%=headerfont%:colour%=headercol%
  21690.  No font: rule
  21691. :font%=bodyfont%:colour%=bodycol%
  21692. TextPtr%?term%=13
  21693.  R%=-3:
  21694.  rule off
  21695.  "Wimp_SetColour",rulewimpcol%
  21696.  x%,y%+linedepth% 
  21697.  BY LenLineP%,0
  21698.  R%=-2:
  21699.  No columns: print whole line
  21700. font_print(TextPtr%,0,x%,y%,font%,colour%)
  21701.  format$="vert":
  21702.   chars%=Tab%(2)-Tab%(1)
  21703. 5  w%=
  21704. how_wide("",TextPtr%,chars%,headerfont%,-1)
  21705.   x%=x0%+maxlenP%(1)-w%
  21706.  chars%>0 
  21707. font_print(TextPtr%,chars%,x%,y%,headerfont%,headercol%):x%+=w%+8
  21708. !  Q%=Tab%(2):ptr%=TextPtr%+Q%
  21709.  P%=0
  21710.  P%+=1
  21711. "    
  21712.  ptr%?P%=160 
  21713.  ptr%?P%=13
  21714. C    
  21715.  Check for concatenation. A CHR$(160) precedes next header
  21716.  ptr%?P%=160 
  21717. 7      
  21718. font_print(ptr%,P%,x%,y%,bodyfont%,bodycol%)
  21719. 8      w%=
  21720. how_wide("",ptr%,P%,bodyfont%,-1):x%+=w%+8
  21721.       ptr%+=P%:P%=0
  21722.       
  21723.  P%+=1
  21724.       
  21725.  ptr%?(P%+1)=160
  21726. 5      
  21727.  "tail" of header ends with this character
  21728. =      
  21729. font_print(ptr%,P%+1,x%,y%,headerfont%,headercol%)
  21730. :      w%=
  21731. how_wide("",ptr%,P%,headerfont%,-1):x%+=w%+8
  21732.       Q%=P%-1:ptr%+=P%+1
  21733.         
  21734.  ptr%?P%=13
  21735. font_print(ptr%,0,x%,y%,bodyfont%,bodycol%)
  21736.  Print in columns
  21737.  F%=1 
  21738.  lastprintable%
  21739.     width%=maxlenP%(F%)
  21740.     P%=TextPtr%+Tab%(F%)
  21741. "    chars%=Tab%(F%+1)-Tab%(F%)
  21742.  numeric%(F%) 
  21743. -      w%=
  21744. how_wide("",P%,chars%,font%,-1)
  21745.       x1%=(width%-w%)
  21746.       
  21747.  x1%=0
  21748.         
  21749. 6    
  21750. font_print(P%,chars%,x%+x1%,y%,font%,colour%)
  21751.     x%+=width%
  21752.  x%>xmax% 
  21753.  xmax%=x%
  21754. get_document_size(
  21755.  "PDriver_PageSize" 
  21756. ,w%,h%,l%,b%,r%,t%
  21757.  "Font_ConverttoOS",,w%,h% 
  21758.  ,w%,h%
  21759.  "Font_ConverttoOS",,l%,r% 
  21760.  ,l%,r%
  21761.  "Font_ConverttoOS",,t%,b% 
  21762.  ,t%,b%
  21763. fit_page
  21764.  x%,y%,w%,column%
  21765.  orientation$ 
  21766.  "upright":
  21767. C  w%=(right%-left%-(gutter%*(printcolumns%-1))) 
  21768.  printcolumns%
  21769.   rectangle%!0=0
  21770.   rectangle%!4=0
  21771.   rectangle%!8=w%
  21772.    rectangle%!12=top%-bottom%
  21773.  column%=1 
  21774.  printcolumns%
  21775. 5    x%=left%+(w%+gutter%)*(column%-1):y%=bottom% 
  21776. P    
  21777.  "Font_Converttopoints",,x%,y% 
  21778.  ,!origin%(column%),origin%(column%)!4
  21779.  column%
  21780.   transform%!0=(1<<16)
  21781.   transform%!4=0
  21782.   transform%!8=0
  21783.   transform%!12=(1<<16)
  21784. <  xstart%=4:ystart%=top%-bottom%-linedepth%:xlimit%=w%-8
  21785.  "sideways":
  21786. C  w%=(top%-bottom%-(gutter%*(printcolumns%-1))) 
  21787.  printcolumns%
  21788.   rectangle%!0=0
  21789.   rectangle%!4=0
  21790.   rectangle%!8=w%
  21791.    rectangle%!12=right%-left%
  21792.  column%=1 
  21793.  printcolumns%
  21794. 7    x%=right%:y%=bottom%+(w%+gutter%)*(column%-1)  
  21795. P    
  21796.  "Font_Converttopoints",,x%,y% 
  21797.  ,!origin%(column%),origin%(column%)!4
  21798.  column%
  21799.   transform%!0=0
  21800.   transform%!4=(1<<16)
  21801.   transform%!8=-(1<<16)
  21802.   transform%!12=0
  21803. <  xstart%=4:ystart%=right%-left%-linedepth%:xlimit%=w%-8
  21804. get_fonts
  21805. Eheaderfont%=
  21806. get_font($
  21807. text(printerW%,57),pointsize%,pointsize%)
  21808. Cbodyfont%=
  21809. get_font($
  21810. text(printerW%,71),pointsize%,pointsize%)
  21811. -keyfont%=
  21812. get_font("Homerton.Medium",4,4)
  21813. get_font(fontname$,width%,height%)
  21814.  font%
  21815.  "Font_FindFont",,fontname$,width%*16,height%*16 
  21816.  font%
  21817. =font%
  21818. declare_fonts
  21819.  "PDriver_DeclareFont",headerfont%
  21820.  "PDriver_DeclareFont",bodyfont%
  21821.  "PDriver_DeclareFont",keyfont%
  21822.  "PDriver_DeclareFont"
  21823. lose_fonts
  21824.  "Font_LoseFont",headerfont%
  21825.  "Font_LoseFont",bodyfont%
  21826.  "Font_LoseFont",keyfont%
  21827. font_print(P%,L%,x%,y%,font%,fontcol%)
  21828.  byte%,S$
  21829.  L%=0 
  21830.  S$=$P% 
  21831.  byte%=P%?L%:P%?L%=13:S$=$P%:P%?L%=byte% 
  21832.  "ColourTrans_SetFontColours",font%,&ffffff00,fontcol%,14
  21833.  "Font_Paint",font%,S$,16,x%,y%
  21834. how_wide(S$,P%,L%,font%,split%)
  21835.  width%
  21836.  "Font_SetFont",font%
  21837. >,Ablock%!0=0:block%!4=0:block%!8=0:block%!12=0:block%!16=split%
  21838. >/?  
  21839.  "Font_ScanString",font%,S$,(1<<5)+(1<<18),-1,-1,block%
  21840. >1J  
  21841.  "Font_ScanString",font%,P%,(1<<5)+(1<<7)+(1<<18),-1,-1,block%,,L%
  21842. width%=block%!28-block%!20
  21843.  "Font_ConverttoOS",,width% 
  21844.  ,width%
  21845. =width%+4
  21846. table_grid(x%,y%,rows%,columns%,colwidth%)
  21847.  width%,height%,C%,R%
  21848.  rows%<=0 
  21849. >:*width%=x%-xstart%+4+colwidth%*columns%
  21850. height%=linedepth%*rows%
  21851.  "Wimp_SetColour",rulewimpcol%
  21852.  xstart%-4,y%,width%,height%
  21853.  xstart%-4,y%-linedepth%
  21854.  R%=1 
  21855.  rows%+1
  21856. >@4  
  21857.  BY 0,linedepth%:
  21858.  BY width%,0:
  21859.  BY -width%,0
  21860. vertical_rules(xstart%-(spacerlen% 
  21861.  2),y%,height%)
  21862.  x%-colwidth%,y%
  21863.  C%<columns%
  21864.   C%+=1
  21865. >F5  
  21866.  BY colwidth%,0:
  21867.  BY 0,height%:
  21868.  BY 0,-height%
  21869. vertical_rules(x%,y%,height%)
  21870.  "Wimp_SetColour",rulewimpcol%
  21871.  x%,y%
  21872.  F%<PrintFields%
  21873. >P8  
  21874.  BY maxlenP%(F%),0:
  21875.  BY 0,height%:
  21876.  BY 0,-height%
  21877.   F%+=1
  21878. memory_usage
  21879.  F,R,f$,S$,P%
  21880. f$=$database%+".MemoryUsed"
  21881. (f$):
  21882.  F=0 
  21883. #F,"Database: "+
  21884. leaf($database%)+" ("+
  21885. $+")"
  21886. #F,"(Record has "+
  21887. (fields%)+" fields and is "+
  21888. (Length%)+" [&"+
  21889. ~(Length%)+"] bytes long)"
  21890. N%=((
  21891. )+1024) 
  21892.  1024
  21893. #F,"Program size: "+
  21894. (N%)+"K"
  21895. N%=((
  21896. P)+1024) 
  21897.  1024
  21898. #F,"Basic variables: "+
  21899. (N%)+"K"
  21900. N%=((
  21901. )+1024) 
  21902.  1024
  21903. ("<Pbase$Dir>.!Run")
  21904.   S$=
  21905. S$,8)="WimpSlot"
  21906. close_file(R)
  21907. S$,"K")-3
  21908. #F,"Program + variables: "+
  21909. (N%)+"K (Wimpslot = "+
  21910. S$,P%,4)+")"
  21911. >g@A%=indirectionmem% 
  21912.  1024:N%=((buff%-buffbase%)+1024) 
  21913.  1024
  21914. >hIM%=endbuff%-buff%:
  21915.  M%<1024 
  21916. (M%)+" bytes" 
  21917.  1024)+"K"
  21918. #F,"Icon indirection: "+
  21919. (A%)+"K allocated, "+M$+" left"
  21920. A%=menumem% 
  21921.  1024
  21922. >kLM%=men_end%-men_top%:
  21923.  M%<1024 
  21924. (M%)+" bytes" 
  21925.  1024)+"K"
  21926. #F,"Menus: "+
  21927. (A%)+"K allocated, "+M$+" left"
  21928. close_file(F)
  21929.  "OS_File",18,f$,&fff
  21930. check_resources
  21931.  f$,imissing$,rmissing$,rpath$,ipath$,d%
  21932. >sArpath$="<PBase$Dir>.Resources.":ipath$="<PBase$Dir>.Initial."
  21933.  f$<>"*"
  21934. >w#  
  21935.  "OS_File",5,rpath$+f$ 
  21936.  d%=0 
  21937. >y%    
  21938.  "OS_File",5,ipath$+f$ 
  21939. >z_    
  21940.  d%=1 
  21941.  "OS_CLI","Copy "+ipath$+f$+" "+rpath$+f$+" ~C~V" 
  21942.  imissing$+=""""+f$+""","
  21943.  f$  
  21944. imissing$=
  21945. imissing$)
  21946.  f$<>"*"
  21947.  "OS_File",5,rpath$+f$ 
  21948.  d%=0 
  21949.  rmissing$+=""""+f$+""","
  21950. rmissing$=
  21951. rmissing$)
  21952.  imissing$<>"" 
  21953.  0,imissing$+" missing from "+program$+".Initial. Please consult Powerbase Support"
  21954.  rmissing$<>"" 
  21955.  0,rmissing$+" missing from "+program$+".Resources. Please consult Powerbase Support"
  21956.  !PrintOpts,Config,CSVoptions,FieldCols,Fkeys,GridOpts,Preference,*
  21957.  Dial,Help,HelpReader,Info,Internet,KeyList,Messages,Sprites,Sprites22
  21958.  Templates,UserMenu,ValStrings,Modules.ImpulseII,Modules.SlidingHp
  21959.  Objects.Draw,Objects.Sprite,Objects.Text,Temp.!Run
  21960.  Temp.!Sprites,Temp.!Sprites22,*
  21961. +Tools%=2:MaxLibs%=10:CustDir$=PbaseDir$
  21962. compare_paths(file$,database$)
  21963.  P%,Q%,L%,C$,P$,T$,leaf$
  21964.  Remotepath$="Absolute" 
  21965. =file$
  21966. file$,"$"):Q%=
  21967. database$,"$")
  21968. file$,P%)<>
  21969. database$,Q%) 
  21970. =file$
  21971.  Not on same filing system: can't use relative path
  21972. leaf$=
  21973. leaf(file$)
  21974.  leafnamepath$=database$+".PrintRes" 
  21975. =leaf$
  21976.  leafnamepath$=database$ 
  21977. leaf(database$)+"."+leaf$
  21978. P$="^."
  21979.   P%+=1
  21980.   C$=
  21981. file$,P%,1)
  21982.  C$="." 
  21983.  L%=Q%:Q%=P%+1
  21984.  C$<>
  21985. database$,P%,1)
  21986. file$,L%)
  21987.   P%=
  21988. database$,".",P%+1)
  21989.  P%>0 
  21990.  P$+="^."
  21991.  P%=0
  21992. T$,".")
  21993. T$,P%+1)
  21994. =P$+T$
  21995. add_button(wi%,S$,type$,grey%,x%,y%,W%)
  21996.  Do not remove or alter this procedure!
  21997.  ic%,L%
  21998. (S$)+1
  21999.  W%=0 
  22000. .  W%=
  22001. string_width(S$)+8:
  22002.  W%<144 
  22003.  W%=144
  22004.  type$ 
  22005.  "menu":
  22006.  wi%=keypadW% 
  22007. 1    
  22008. (name$+"window%")=-1 
  22009.  toolheight%+=52
  22010. !    x%=xm%:y%=ym%:W%=44:S$=""
  22011. _  ic%=
  22012. create_icon(0,wi%,x%,y%,W%,44,&17003133,"",buff%,valid%(33),1):$buff%=S$:buff%+=L%+1
  22013.  "window":
  22014.  wi%=keypadW% 
  22015. /    
  22016. (name$+"menu%")=-1 
  22017.  toolheight%+=52
  22018. !    x%=xw%:y%=yw%:W%=44:S$=""
  22019. [  ic%=
  22020. create_icon(0,wi%,x%,y%,W%,44,&17003133,"",buff%,winsp%,1):$buff%=S$:buff%+=L%+1
  22021.  Tools% 
  22022. #    
  22023.  No keypad or toolpane
  22024.  wi%=keypadW% 
  22025. &      
  22026.  button%=0 
  22027.  padheight%+=52
  22028. +      x%=8+button%*166:y%=-padheight%+6
  22029. !      button%=(button%+1) 
  22030. ?    
  22031.  wi%=keypadW% 
  22032.  toolheight%+=52:x%=4:y%=-toolheight%+2
  22033.  type$ 
  22034.  "option":
  22035. e    ic%=
  22036. create_icon(0,wi%,x%,y%,144,48,&1700B133,"",buff%,valid%(82),L%+1):$buff%=S$:buff%+=L%+1
  22037.  "radio":
  22038. "    $buff%="Sradiooff,radioon"
  22039. i    ic%=
  22040. create_icon(0,wi%,x%,y%,144,48,&1701B133,"",buff%+18,buff%,L%+1):$(buff%+18)=S$:buff%+=L%+19
  22041. d    ic%=
  22042. create_icon(0,wi%,x%,y%,W%,48,&1700353D,"",buff%,valid%(32),L%+1):$buff%=S$:buff%+=L%+1
  22043. shade(wi%,ic%,
  22044.  grey%)
  22045. find_libraries(dir$,
  22046.  NX%,N%)
  22047.  L%,d%,R4%,name$,f$,flag%
  22048.  "OS_GBPB",9,dir$,block%,1,R4%,255 
  22049.  ,,name$,,R4%
  22050.  R4%<>-1
  22051. /  f$=dir$+"."+name$+".Customise."+
  22052. name$,2)
  22053.  "OS_File",5,f$ 
  22054.  d%,,,,L%
  22055.  d%=0 
  22056.  f$=dir$+"."+name$+".Customise.Demo":
  22057.  "OS_File",5,f$ 
  22058.  d%,,,,L%
  22059.  d%=1 
  22060.  NX%<N% 
  22061.       
  22062. unique(f$,NX%+1) 
  22063. 8        
  22064.  Don't store a given library more than once
  22065.         lib$(NX%)=f$:NX%+=1
  22066.         
  22067.  L%>M% 
  22068.  M%=L%
  22069.       
  22070. 2      
  22071.  flag% 
  22072. softerror("",236):flag%=
  22073.         
  22074.  "OS_GBPB",9,dir$,block%,1,R4%,255 
  22075.  ,,name$,,R4%
  22076.  M%>0 
  22077.  lib$()
  22078. unique(f$,N%)
  22079.  lib$,flib$,ok%,l$
  22080. flib$=
  22081. leaf(f$)
  22082.    N%-=1:lib$=
  22083. leaf(lib$(N%))
  22084.  N%=0 
  22085.  lib$=flib$
  22086.  lib$=flib$ 
  22087.  ok%=
  22088.  ok%=
  22089.  ok% 
  22090. lit(utilityM%,10,
  22091. lit(iconbarM%,2,
  22092.